Bug 150778 - Add objC delegate callback for webProcessDidBecomeResponsive and webProcessDidBecomeUnresponsive.
Summary: Add objC delegate callback for webProcessDidBecomeResponsive and webProcessDi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-11-01 11:47 PST by Yongjun Zhang
Modified: 2015-11-02 10:27 PST (History)
8 users (show)

See Also:


Attachments
Patch. (10.95 KB, patch)
2015-11-01 12:28 PST, Yongjun Zhang
no flags Details | Formatted Diff | Diff
Fix style issues. (10.94 KB, patch)
2015-11-01 12:36 PST, Yongjun Zhang
darin: review+
Details | Formatted Diff | Diff
Address review comments for landing. (11.32 KB, patch)
2015-11-01 14:18 PST, Yongjun Zhang
no flags Details | Formatted Diff | Diff
Address review comments before landing. (9.57 KB, patch)
2015-11-01 14:20 PST, Yongjun Zhang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yongjun Zhang 2015-11-01 11:47:48 PST
It would be nice for a WebKit client to get notified if the web process becomes unresponsive or responsive. To that, we should consider to add delegate methods for webProcessDidBecomeResponsive and webProcessDidBecomeUnresponsive.
Comment 1 Yongjun Zhang 2015-11-01 11:48:56 PST
<rdar://problem/23288706>
Comment 2 Yongjun Zhang 2015-11-01 12:28:27 PST
Created attachment 264525 [details]
Patch.
Comment 3 WebKit Commit Bot 2015-11-01 12:30:54 PST
Attachment 264525 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.h:104:  The parameter name "page" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.h:105:  The parameter name "page" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 2 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Yongjun Zhang 2015-11-01 12:36:09 PST
Created attachment 264526 [details]
Fix style issues.
Comment 5 Darin Adler 2015-11-01 12:43:17 PST
Comment on attachment 264526 [details]
Fix style issues.

View in context: https://bugs.webkit.org/attachment.cgi?id=264526&action=review

> Source/WebKit2/UIProcess/API/APINavigationClient.h:87
>      // FIXME: This function should not be part of this client.
>      virtual void processDidCrash(WebKit::WebPageProxy&) { }
> +    virtual void processDidBecomeResponsive(WebKit::WebPageProxy&) { }
> +    virtual void processDidBecomeUnresponsive(WebKit::WebPageProxy&) { }

If the comment applies to all three of these, then please reword it so it says “These functions”.

Why can’t WebKit2 implement the delegate by implementing the existing loader client function? Why do we have to add this to the navigation client?

> Source/WebKit2/UIProcess/Cocoa/NavigationState.h:105
> +        virtual void processDidBecomeResponsive(WebKit::WebPageProxy&) override;
> +        virtual void processDidBecomeUnresponsive(WebKit::WebPageProxy&) override;

Please, no WebKit:: prefix here for the argument types for these new functions (match the function just above).

> Source/WebKit2/UIProcess/Cocoa/NavigationState.h:188
> +        bool webViewWebProcessDidBecomeResponsive : 1;
> +        bool webViewWebProcessDidBecomeUnresponsive : 1;

Not sure what order these booleans are in. It’s strange to have the new ones at the bottom after the QuickLook ones. Maybe we should keep these alphabetical instead of randomly ordered?

> Source/WebKit2/UIProcess/WebPageProxy.cpp:4863
> -    m_loaderClient->processDidBecomeUnresponsive(*this);
> +    if (m_navigationClient)
> +        m_navigationClient->processDidBecomeUnresponsive(*this);
> +    else
> +        m_loaderClient->processDidBecomeUnresponsive(*this);

Skipping the loader client function just because we have a navigation client doesn’t seem logical. Seems we should call both.

> Source/WebKit2/UIProcess/WebPageProxy.cpp:4884
> -    m_loaderClient->processDidBecomeResponsive(*this);
> +    if (m_navigationClient)
> +        m_navigationClient->processDidBecomeResponsive(*this);
> +    else
> +        m_loaderClient->processDidBecomeResponsive(*this);

Ditto.
Comment 6 Yongjun Zhang 2015-11-01 14:09:23 PST
(In reply to comment #5)
> Comment on attachment 264526 [details]
> Fix style issues.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=264526&action=review
> 
> > Source/WebKit2/UIProcess/API/APINavigationClient.h:87
> >      // FIXME: This function should not be part of this client.
> >      virtual void processDidCrash(WebKit::WebPageProxy&) { }
> > +    virtual void processDidBecomeResponsive(WebKit::WebPageProxy&) { }
> > +    virtual void processDidBecomeUnresponsive(WebKit::WebPageProxy&) { }
> 
> If the comment applies to all three of these, then please reword it so it
> says “These functions”.

I will change.
> 
> Why can’t WebKit2 implement the delegate by implementing the existing loader
> client function? Why do we have to add this to the navigation client?
>

Looks like WebKit2 does have loader client delegate, but it is only implemented as the deprecated WKBrowsingContextLoadDelegatePrivate, which is where browsingContextControllerWebProcessDidCrash: stays. This patch follows the way how _webViewWebProcessDidCrash and webViewWebContentProcessDidTerminate: are implemented, and they are currently staying in the negation client (WKNavigationDelegate).
 
> > Source/WebKit2/UIProcess/Cocoa/NavigationState.h:105
> > +        virtual void processDidBecomeResponsive(WebKit::WebPageProxy&) override;
> > +        virtual void processDidBecomeUnresponsive(WebKit::WebPageProxy&) override;
> 
> Please, no WebKit:: prefix here for the argument types for these new
> functions (match the function just above).

Fixed.

> 
> > Source/WebKit2/UIProcess/Cocoa/NavigationState.h:188
> > +        bool webViewWebProcessDidBecomeResponsive : 1;
> > +        bool webViewWebProcessDidBecomeUnresponsive : 1;
> 
> Not sure what order these booleans are in. It’s strange to have the new ones
> at the bottom after the QuickLook ones. Maybe we should keep these
> alphabetical instead of randomly ordered?

Yeah, the ordering seems to random - they are not alphabetical. I will move these two bools next to webViewWebProcessDidCrash since they belong to the same category (webProcess related).
> 
> > Source/WebKit2/UIProcess/WebPageProxy.cpp:4863
> > -    m_loaderClient->processDidBecomeUnresponsive(*this);
> > +    if (m_navigationClient)
> > +        m_navigationClient->processDidBecomeUnresponsive(*this);
> > +    else
> > +        m_loaderClient->processDidBecomeUnresponsive(*this);
> 
> Skipping the loader client function just because we have a navigation client
> doesn’t seem logical. Seems we should call both.

Again, this is following the pattern of WebPageProxy::processDidCrash(). I agree it is odd to skip the loader client. Will file another bug.
> 
> > Source/WebKit2/UIProcess/WebPageProxy.cpp:4884
> > -    m_loaderClient->processDidBecomeResponsive(*this);
> > +    if (m_navigationClient)
> > +        m_navigationClient->processDidBecomeResponsive(*this);
> > +    else
> > +        m_loaderClient->processDidBecomeResponsive(*this);
> 
> Ditto.
Comment 7 Yongjun Zhang 2015-11-01 14:18:07 PST
Created attachment 264530 [details]
Address review comments for landing.
Comment 8 Yongjun Zhang 2015-11-01 14:20:38 PST
Created attachment 264531 [details]
Address review comments before landing.
Comment 9 WebKit Commit Bot 2015-11-02 10:27:31 PST
Comment on attachment 264531 [details]
Address review comments before landing.

Clearing flags on attachment: 264531

Committed r191895: <http://trac.webkit.org/changeset/191895>
Comment 10 WebKit Commit Bot 2015-11-02 10:27:35 PST
All reviewed patches have been landed.  Closing bug.