Search code examples
androidwebviewchromiumandroid-4.4-kitkathardware-acceleration

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.

Solution

  • 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.