Surface - dequeueBuffer failed (Unknown error 2147483646)

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

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 honestly don't see a way to fix this, I've read a fair amount of answers at SO to problems on webview but I still couldn't fix the problem.
I would appreciate a light here!

回答1:

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

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!