[WebView] callback methods of onPageStarted & onPageFinished

1,287 views
Skip to first unread message

Callia

unread,
Nov 20, 2015, 4:14:07 AM11/20/15
to Chromium-dev
HI, 

I'd like to discuss the calling method for page loading & page finished on WebView.

For a page loading, chromium uses UI main thread to run 2 important callbacks in order to notify WebView that page loading timing change.

1. onPageStarted (notify page is staring to load)
    - InterceptNavigationDelegate::ShouldIgnoreNavigation --> AwContents$InterceptNavigationDelegateImpl.shouldIgnoreNavigation -->post a message(async call) do to WebViewContentsClientAdapter.onPageStarted
2. onPageFinished (notify page loading done)
    - WebContentsObserverProxy.didFinishLoad --> blocking call WebViewContentsClientAdapter.onPageFinished
 
Because it’s a async call to run WebViewContentsClientAdapter.onPageStarted, it dose not gurantee that WebViewContentsClientAdapter.onPageStarted executing before WebViewContentsClientAdapter.onPageFinished.
Sometimes, page loading callback is out of order, like this issue.
 
 
In order to consistent callback sequence, onPageStartedd and onPageFinished should BOTH are blocking or BOTH are async call. How about changing to use post message (async call) to trigger onPageFinished?
Thanks you.
 

Example:
/android_webview/java/src/org/chromium/android_webview/AwWebContentObserver.java
    @Override
    public void didFinishLoad(long frameId, String validatedUrl, boolean isMainFrame) {
        AwContentsClient client = mAwContentsClient.get();
        if (client == null) return;
        String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUrl();
        boolean isErrorUrl =
                unreachableWebDataUrl != null && unreachableWebDataUrl.equals(validatedUrl);
        if (isMainFrame && !isErrorUrl) {
            //
            //client.onPageFinished(validatedUrl);
            //
            client.getCallbackHelper().postOnPageFinished(validatedUrl);
        }
    }

Mikhail Naganov

unread,
Nov 20, 2015, 12:19:20 PM11/20/15
to calli...@mediatek.com, Chromium-dev
Hi Callia,

Thanks for your interest in WebView! What version are you referring to? I think we might have something like that in older versions, but in the current code onPageFinished is always posted. You can check the latest version of AwWebContentsObserver here: https://code.google.com/p/chromium/codesearch#chromium/src/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Reply all
Reply to author
Forward
0 new messages