Am having a weird issue working with chromium webview on Android Kitkat [Chromium 30].
Sometimes the web content fails to load with this printed in the logs:
nativeondraw failed clearing to background color
Just a blank screen is with zeta theme color as background is shown. This issue randomly occurs a few times, while using the app.
I checked out several resources and most of them suggest turning off hardware acceleration for the webview because it seems to be because hardware accelerated canvas rendering is not supported in Chromium WebView.
References:
- WebView Rendering Issue in Android KitKat
- Android WebView got white page nativeOnDraw failed; clearing to background color
- https://github.com/mogoweb/chromium_webview/issues/4
- https://bugs.chromium.org/p/chromium/issues/detail?id=433666
Theres definitely a bad impact of turning off hardware acceleration for the webview.
- The rendering before disabling hardware acceleration is below 16ms for most of the times.
- After disabling, its consistently above 16ms.
Moreover, "Could not lock surface" seems to be a related issue. Searching for solutions, points at the same solution.
Could not lock surface
E java.lang.IllegalArgumentException
E at android.view.Surface.nativeLockCanvas(Native Method)
E at android.view.Surface.lockCanvas(Surface.java:246)
E at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2435)
E at android.view.ViewRootImpl.draw(ViewRootImpl.java:2409)
E at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2253)
E at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1883)
E at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
E at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
E at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
E at android.view.Choreographer.doCallbacks(Choreographer.java:574)
E at android.view.Choreographer.doFrame(Choreographer.java:544)
E at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
E at android.os.Handler.handleCallback(Handler.java:733)
E at android.os.Handler.dispatchMessage(Handler.java:95)
E at android.os.Looper.loop(Looper.java:137)
E at android.app.ActivityThread.main(ActivityThread.java:4998)
E at java.lang.reflect.Method.invokeNative(Native Method)
E at java.lang.reflect.Method.invoke(Method.java:515)
E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:811)
E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627)
E at dalvik.system.NativeStart.main(Native Method)