5

I've been struggling for 3 days with an android app that uses a webview to load my website that contains thousands of images. The application start well but after scrolling trough a couple hundred images the webview freezes (it doesn't force-close) the logcat (check it on pastebin) shows

E/Surface dequeueBuffer failed (Unknown error 2147483646)

What I've tried:

  1. Limit the number of images on every activity, when a user views 100 images, start another activity.
  2. Clear the webview cache onCreation, onPause, onStop, etc... clearCache(true);
  3. Set the webview cache to false setAppCacheEnabled(false);
  4. Kill activity A after opening activity B and vice versa
  5. Set the webView.setLayerType() to NONE, SOFTWARE and HARDWARE
  6. Declare "android:largeHeap="true" and android:hardwareAccelerated="true" on the manifest.
  7. Put the webview inside a placeholder a remove it before finish();

webViewPlaceholder.removeView(myWebView);  
myWebView.removeAllViews();  
myWebView.destroy();

It seems that android keeps the webview in memory and cleaning the cache doesn't have any effect.
When I close the app and reopen it the error appears immediately, so it seems that not even closing the app releases the memory it uses.
I've read a fair amount of answers at SO regarding webview problems , but I still couldn't fix the problem and any help is very much appreciated.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • Hi, I am also having similar problems. Can you help if you were able to fix this problem? – isa Apr 14 '22 at 07:15
  • @isa This question is 8 years old and I honestly don't remember the context or project and if I actually solved the problem. – Pedro Lobito Apr 14 '22 at 07:26

1 Answers1

0

for KitKat 4.4.3 or later set the hardware acceleration to false:

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
ks32
  • 9
  • 1
  • 2