Android Webview: Cannot call determinedVisibility() - never saw a connection for the pid

前端 未结 11 885
南笙
南笙 2020-12-01 14:11

I have a Android Webview and when I click on a link to download a file (image of pdf etc) I got a error message.

Error message:
Cannot call determinedVisibil         


        
相关标签:
11条回答
  • 2020-12-01 14:29

    Late to party, but might help some. May sound silly as hell, but the mistake I made was not adding http:// in the beginning of the URL.

    0 讨论(0)
  • 2020-12-01 14:31
    mWebView.setDownloadListener(new DownloadListener() {
      @Override
      public void onDownloadStart(String url, String userAgent, String contentDisposition, 
        String mimetype, long contentLength) {
        Log.d("download",url);
      }
    });
    
    0 讨论(0)
  • 2020-12-01 14:39

    I got the same error and Burhans solution was not helping me. I think things went wrong when you´re trying to load different urls too fast.

    Edit: Found a better solution credits go to user2652394 WebView must be loaded twice to load correctly

    You have to do something like this:

            webView.postDelayed(new Runnable() {
    
                @Override
                public void run() {
                    webView.loadUrl(landingpage);
                }
            }, 500);
    
    0 讨论(0)
  • 2020-12-01 14:46

    Background

    Here is the source code of the method in the browser engine that gives the error (BindingManagerImpl.java), from Chromium source:

    @Override
    public void determinedVisibility(int pid) {
        ManagedConnection managedConnection;
        synchronized (mManagedConnections) {
            managedConnection = mManagedConnections.get(pid);
        }
        if (managedConnection == null) {
            Log.w(TAG, "Cannot call determinedVisibility() - never saw a connection for the pid: "
                    + "%d", pid);
            return;
        }
    

    Analysis

    It's a rendering warning from content.

    Consecutive calls to loadUrl cause a race condition. The problem is that loadUrl("file://..") doesn't complete immediately, and so when you call loadUrl("javascript:..") it will sometimes execute before the page has loaded.

    Detail

    For more detail see this stackoverflow answer.

    0 讨论(0)
  • 2020-12-01 14:46

    I found a workaround by using onPageFinished method instead of shouldOverrideUrlLoading. It also provides the needed URL in the list of arguments.

    The only trick is to set a check so that the main logic of the method (in my case making a Toast) is not triggered when onPageFinished gets called on the the page load itself.

    0 讨论(0)
提交回复
热议问题