Android : EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up

19,821

Solution 1

The issue I found was because of the url without http:// or https://. So I appended this tag if the url doesn't contains http:// or https://.

Solution 2

In my case, I fixed it by changing the order. I put the loadUrl before getSettings()

Working snippet below,

mWebView = (WebView) findViewById(R.id.web_view);

// load file
mWebView.loadUrl(SERVER_URL);
mWebView.getSettings().setJavaScriptEnabled(true);

Hope this helps someone..

Solution 3

I've seen this stack sometimes during the last days in my LogCat, but until now it wasn't blocking my dev. But I suspect it's related to the struggling my WebView somtetimes does. It seems to be a Bug affecting not only us:


android.webkit.WebViewCore.removeMessages(int):void

1675        private synchronized void removeMessages(int what) {
1676            if (mBlockMessages) {
1677                return;
1678            }
1679            if (what == EventHub.WEBKIT_DRAW) {
1680                mDrawIsScheduled = false;
1681            }
1682            if (mMessages != null) {
1683                Throwable throwable = new Throwable(
1684                        "EventHub.removeMessages(int what = " + what + ") is not supported " +
1685                        "before the WebViewCore is set up.");
1686                Log.w(LOGTAG, Log.getStackTraceString(throwable));
1687            } else {
1688                mHandler.removeMessages(what);
1689            }
1690        }

The Queue mMessages has to be NULL to avoid the Exception.

// Message queue for containing messages before the WebCore thread is ready.

So it's quite simple: something is causing the WebCore to need much more time to set up. According that 107 is `SET_SCROLL_OFFSET' and the stack-trace shows ZoomManger I will check if something in my code is causing the view to get active in some way while initiating the settings.


ANSWER: This exception will be thrown if you call requestWindowFeature(Window.FEATURE_NO_TITLE) and then wait too long for calling setContentView(). How long you can wait I couldn't figure out. So those two will be the first lines in onCreate() from now. Time will show me if I'm right.

The good news are that this warning tagged webcore is only a warning and itself causes no impact to the rest of the app.

The bad news are that it seems that my problem has nothing to do with it and comes from somewhere other.

Solution 4

The issue is generally related to the URL being pointed to not being found. It is a 404 (i.e. a URL that wasn't found). Modify the URL

Share:
19,821
Vishal Khakhkhar
Author by

Vishal Khakhkhar

Updated on June 05, 2022

Comments

  • Vishal Khakhkhar
    Vishal Khakhkhar almost 2 years

    I have implemented WebView in Dialog Activity and I am loading simple url into webview.

    my Webview settings are as

    wbView = (WebView) findViewById(R.id.wbView);
            wbView.setKeepScreenOn(true);
            wbView.getSettings().setJavaScriptEnabled(true);
            wbView.getSettings().setDomStorageEnabled(true);
            wbView.getSettings().setBuiltInZoomControls(true);
            wbView.setInitialScale(100);
            // wbView.getSettings().setUseWideViewPort(true);
            wbView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
            wbView.setWebViewClient(new MyWebViewClient());
    

    and MyWebViewClient() contains

    private class MyWebViewClient extends WebViewClient {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                prgBar.setVisibility(View.GONE);
            }
    
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler,
                    SslError error) {
                Log.e("Error VAGARO", error.toString());
                prgBar.setVisibility(View.GONE);
                handler.proceed();
            }
    
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return false;
            }
        }
    

    I am loading two HTML files from the Asset in the same webview its working fine but unable to load dynamic url.

    I Google and find some posts on http://code.google.com/p/android/issues/detail?id=21177

    My logcat shows me

    05-09 13:33:30.187: W/webcore(20054): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1683)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:926)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1795)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebView.sendOurVisibleRect(WebView.java:2917)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
    05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
    05-09 13:33:30.187: W/webcore(20054):   at android.os.Handler.handleCallback(Handler.java:605)
    05-09 13:33:30.187: W/webcore(20054):   at android.os.Handler.dispatchMessage(Handler.java:92)
    05-09 13:33:30.187: W/webcore(20054):   at android.os.Looper.loop(Looper.java:137)
    05-09 13:33:30.187: W/webcore(20054):   at android.app.ActivityThread.main(ActivityThread.java:4424)
    05-09 13:33:30.187: W/webcore(20054):   at java.lang.reflect.Method.invokeNative(Native Method)
    05-09 13:33:30.187: W/webcore(20054):   at java.lang.reflect.Method.invoke(Method.java:511)
    05-09 13:33:30.187: W/webcore(20054):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    05-09 13:33:30.187: W/webcore(20054):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    05-09 13:33:30.187: W/webcore(20054):   at dalvik.system.NativeStart.main(Native Method)
    

    Suggest me the change that I should make.

    Update

    I found that if I'll pass any url like "www.facebook.com" then its giving me this error, but if I'll replace it with "https://www.facebook.com" then its working fine.

  • Rupert Rawnsley
    Rupert Rawnsley almost 11 years
    I just had the same issue on a Toshiba AT300 (Android 4.0.3) because of a trailing slash on the URL: scratch.mit.edu/projects/editor
  • Someone Somewhere
    Someone Somewhere over 10 years
    I get the same problem. Using WebView.loadUrl("http:///www.google.com"); works. However, as soon as I try WebView.loadUrl("file:///android_asset/html5video.html"); it shows the exception. /facepalm
  • krunal shah
    krunal shah almost 9 years
    @VishalKhakhkhar what about if need to load "HTML" type string ?