Unfortunately I cannot reliably reproduce this error but infrequently I get it and occasionally it gets reported in the live crash logs also. Here’s a stacktrace reported by user with Droid 2.2.2 FRG83G
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertNull(Assert.java:233)
at junit.framework.Assert.assertNull(Assert.java:226)
at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:594)
at java.lang.Thread.run(Thread.java:1096)
This seems to be due to this line in WebViewCore.java
Assert.assertNull(sWebCoreHandler);
Somehow sWebCoreHandler which is private static instance of android.os.Handler is not (Thanks @Idolon for the correction) already initialized but I have no clue how to work around or prevent this issue.
This occurs often enough for me to worry. What is also interesting is seemingly happens when the app is loading Activity that doesn’t even have WebView though one of the activities does have it.
P.S. This was filed as bug #16258
Looking at the incriminating source code…
This is executed in the constructor of any
WebViewand the assertion error comes from theWebCoreThreadconstructor, which is only called when thesWebCoreHandleris null, so this assertion should never fail… in theory. Except it’s ran outside of the synchronized clause and inside a new Thread that is created and started inside a synchronized clause, supposedly only once.It seems your error is tied to concurrent creation of webviews. If your application has only one activity with one webview, make sure that this activity is not called more often than necessary (=one at a time), that the WebView is created in the onCreate method rather than the activity constructor, that the startActivity is called in the main thread, and you should be good.