Surface - dequeueBuffer failed (Unknown error 2147483646) - android

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:
Limit the number of images on every activity, when a user views 100
images, start another activity.
Clear the webview cache onCreation, onPause, onStop, etc...
clearCache(true);
Set the webview cache to false setAppCacheEnabled(false);
Kill activity A after opening activity B and vice versa
Set the webView.setLayerType() to NONE, SOFTWARE and HARDWARE
Declare "android:largeHeap="true" and
android:hardwareAccelerated="true" on the manifest.
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.

for KitKat 4.4.3 or later set the hardware acceleration to false:
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Related

Why my Unity game in Android freezes when calling LoadScene?

The game freezes permanently when I try to load the next scene but when I load it with "Additive" mode it's loaded fine (using SceneManager.LoadScene("NextScene", LoadSceneMode.Additive)).
In editor everything works even with mode "Single", the problem only appears with Android.
I don't want to use the "Additive" mode because it loads the content of the new scene above the old one.
I try:
using "adb logcat" to see if any exception occurs but there are no exceptions.
load an empty scene as a new scene but the problem still appears.
load using SceneManager.LoadSceneAsync("NextScene") but the problem still appear.
load with "Additive" mode and after the next scene is loaded I try to Unload the old scene using SceneManager.UnloadScene("OldScene") but it freezes again.
So the problem appears when Unity try to unload the old scene.
(I use Unity 2018.4.10f1 LTS).
Thanks in advance for any help.
Try to delete the objects from the last scene
In for loop to see what object response for the error
I try to build the game with PC and I face the same problem.
I see what in the output_log.txt file in "C:/Users/.../AppData/Local/Temp/.../My game name/Crashes" and the first readable messages after the crash are like this:
"ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFEF20E5212)"
without any other errors or exceptions by my game,
so I try to test the game with an updated version of Unity (2018.4.10f1 --> 2018.4.20f1),
Abracadabra everything works fine with the new version!!
and the problem doesn't appear anymore!!
I think it was a memory management problem in Unity 2018.4.10f1 but I don't know why.

WebViewClient.onRenderProcessGone() not called on crashing WebView first

I have an app that can have multiple WebViews at the same time. Every once in a while the app crashes with a native error
SIGTRAP: Trace/breakpoint trap
at 0x7a587dd494(/data/app/com.android.chrome-7kzKsZs3wawWfQ1TQ0h58w==/base.apk!/lib/arm64-v8a/libmonochrome.so:25011348)
I was able to track it down to a WebView renderer issue which i can simulate by loading a faulty javascript like webView.evaluateJavascript("javascript:(function() { txt = \"a\"; while(1){ txt += \"a\"; } })();", null);.
I am now trying to figure out what page causes the problem in the production app. For that I am overriding WebViewClient.onRenderProcessGone() and want to log the loaded URL at that point. The problem that I have is that, since I have multiple WebViews, I cannot be sure that onRenderProcessGone() is called first on the one that actually caused the crash.
From the WebViewClient doc: Multiple WebView instances may be associated with a single render process. onRenderProcessGone will be called for each WebView that was affected.
My question is, in WebViewClient.onRenderProcessGone(), how can I know which WebView/WebViewClient has caused the crash?
This question got answered in the android-webview-dev google group. Unfortunately there is currently no way to know which webview has crashed.

Images randomly break in PhoneGap/WebView on Android 4.4

I am experiencing a strange bug in PhoneGap on Android 4.4, for which I couldn't find any solution online. In my app, I am loading a lot of different images from a remote server, and as the user navigates back and forth, new images are loaded on each page (4 at a time, to be specific, through jQuery-generated html). After having navigated back and forth for a little while, some images will randomly not show up and instead show the typical "broken image" icon.
Now, here comes the strange part: I have been following the instructions at jQuery/JavaScript to replace broken images and done a few tests of my own. In conclusion, the naturalWidth and naturalHeight parameters report the right sizes of the images, and complete reports true for all images. Therefore, the solutions mentioned in the above SO thread don't work at all. Changing the image src doesn't help, either with or without a setTimeout (I tried adding the current timestamp as a parameter to the image path as well).
Did anyone else encounter this issue at all, or am I going crazy here? :)
EDIT: By the way, no error is ever reported. Therefore, no error handler is called when loading the image, making it useless to solve the problem with the already suggested methods (see the link above).
This is how i handle error images,
<img src="images/imageName.jpg" onError="onErrorFunc(this);" alt=" " />
function onErrorFunc(elem){
var imgUrl = "https://alternative-image";
elem.onerror = function (){
elem.src='images/noimage.jpg';
}
elem.src=imgUrl;
}
Hope it helps!

Android Webview on 4.4 freezes with nativeOnDraw failed; clearing to background color

I know this question has been asked many times and there are few work arounds.But none of them work for me
I have a app that uses webview . On opening many apps and then waking up this app sometimes makes the webview blank. Other components of the app works but the webview is stuck.
I disabled the hardware acceleration in Androidmanifest.xml and it did not work
<application
android:name="com.nandish.app.MyApplication"
android:largeHeap="true"
android:hardwareAccelerated="false">
I tried to add the following line in to the constructor of Webview
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Even this does not work. I am able to reproduce the blank screen consistently. When it freezes, the error message on logs are
09-11 23:29:31.237: W/AwContents(2976): nativeOnDraw failed; clearing to background color.
The problem with my code was the webView object that was used was getting edited in other place since it was a static variable. My Bad, that was complete disaster to use this object as static. Once I converted to instance variable, it worked.
I had the same issue with my WebView and found a pretty simple solution. In my case it was only the way I was giving it the url to load.
Check if your url includes the "http://" in the beginning.
I was trying to load the url from a string with only "www.google.com" and had the "AwContents nativeOnDraw failed; clearing to background color" message on LogCat and a frustrating white screen instead of my site view, this only on KitKat, testing my app on GingerBread was fine.
Just by changing it to "http://www.google.com" everything went well.
No hardware acceleration disabled and complete backwards compatibility.
I met the same warning message
01-14 21:08:15.854 9400-9400/com.xiaomi.adecom W/AwContents: nativeOnDraw failed; clearing to background color.
When the webview trying to load an invalid url, such as empty url string, or the url string is not started with "http://", the warning occurs.

WebView throws Receiver not registered: android.widget.ZoomButtonsController

I see this exception sporadically raising up in my application (in the wild).
The WebView is used to display a jpg (using the zoom/scroll-capabilities of the Android version/the device instead reinventing the wheel and do all the reflection stuff).
I have no idea why this exception eventually could come up. Basically I can only think of an Android bug.
What I do (everything in GUI thread):
display a thumbnail as preview first
set getSettings().setBuiltInZoomControls(false)
when the regular picture is loaded, display that one instead
set getSettings().setBuiltInZoomControls(true)
Why setting ZoomControls on/off: The thumb should not be zoomable, as the WebView resets this on loadData as soon as the regular picture is available and displayed. Would be some bad user experience.
Example device this is happening:
HTC Desire#htc_wwe/htc_bravo/bravo/bravo:2.2/FRF91/226611:user/release-keys
I have exactly the same device/software and it never happend to me...
Any ideas?
Regards,
Oliver
I don't like to answer myself, but littleFluffyKitty did not (only in comment).
Solution is in How to safely turn WebView zooming on and off as needed
a) create your own WebView class
public class MyWebView extends WebView {
b) add in it's onDestroy() method:
getSettings().setBuiltInZoomControls(true);
That's it. Thanks to that, no more of those Exceptions show up.

Categories

Resources