Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

takeScreenshot : width and height must be > 0 #90

Open
juliengit2 opened this issue May 6, 2019 · 4 comments
Open

takeScreenshot : width and height must be > 0 #90

juliengit2 opened this issue May 6, 2019 · 4 comments

Comments

@juliengit2
Copy link

juliengit2 commented May 6, 2019

When calling InAppWebViewController.takeScreenshot

example:

webView.loadData(data).then((e) {
  webView.takeScreenshot().then((bytes) {
  ..
 });
});

we get from time to time :

Failed to handle method call
E/MethodChannel#com.pichillilorenzo/flutter_inappwebview_145(20772): java.lang.IllegalArgumentException: width and height must be > 0
E/MethodChannel#com.pichillilorenzo/flutter_inappwebview_145(20772): at android.graphics.Bitmap.createBitmap(Bitmap.java:933)
E/MethodChannel#com.pichillilorenzo/flutter_inappwebview_145(20772): at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
E/MethodChannel#com.pichillilorenzo/flutter_inappwebview_145(20772): at android.graphics.Bitmap.createBitmap(Bitmap.java:879)

and there is also this memory issue from time to time :

<sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
E/Adreno-GSL(20772): <gsl_memory_alloc_pure:2044>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
W/Adreno-GSL(20772): <sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
E/Adreno-GSL(20772): <gsl_memory_alloc_pure:2044>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
W/Adreno-ES20(20772): <core_glTexImage2D:539>: GL_OUT_OF_MEMORY

Any idea?

@vladimirmedyannikov
Copy link

Trying call takeScreenshot after onLoadStop in InAppWebView, i get an exception

Call example:
onLoadStop: (InAppWebViewController controller, url) async { final bytes = await controller.takeScreenshot(); }

Exception:
java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:1113) at android.graphics.Bitmap.createBitmap(Bitmap.java:1080) at android.graphics.Bitmap.createBitmap(Bitmap.java:1030) at android.graphics.Bitmap.createBitmap(Bitmap.java:991) at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebView$4.run(InAppWebView.java:865)

Maybe need to return null if an image error occurs?

@pichillilorenzo
Copy link
Owner

@juliengit2 can you test using the latest version? However, the plugin name now is flutter_inappwebview! Can you share your code?

@vladimirmedyannikov which version of the plugin are you using?? Also, can you share your code?

Thanks!

@vladimirmedyannikov
Copy link

vladimirmedyannikov commented Dec 5, 2019

@pichillilorenzo now test v2.1.0+1
Exception still exists

InAppWebView(
                                initialUrl: url,
                                initialOptions: InAppWebViewWidgetOptions(
                                  inAppWebViewOptions: InAppWebViewOptions(
                                      useShouldOverrideUrlLoading: true,
                                      useOnLoadResource: true,
                                      javaScriptEnabled: true,
                                      incognito: true,
                                      mediaPlaybackRequiresUserGesture: false,
                                      clearCache: true,
                                      javaScriptCanOpenWindowsAutomatically: false,
                                  ),
                                  androidInAppWebViewOptions: AndroidInAppWebViewOptions(),
                                  iosInAppWebViewOptions: IosInAppWebViewOptions(
                                      allowsAirPlayForMediaPlayback: false,
                                  allowsInlineMediaPlayback: true),
                                ),
                                onLoadStop: (InAppWebViewController controller,
                                    message) async {
                                  final res = await controller.takeScreenshot();
                                })

@pichillilorenzo
Copy link
Owner

@vladimirmedyannikov can you also provide the URL to test? thanks!

This was referenced Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants