Changeset 272990 in webkit


Ignore:
Timestamp:
Feb 17, 2021 1:38:47 AM (3 years ago)
Author:
Chris Dumez
Message:

Regression(r268097): Calling processDidTerminate delegate asynchronously is risky compatibility-wise
https://bugs.webkit.org/show_bug.cgi?id=222011

Reviewed by Carlos Garcia Campos.

Calling processDidTerminate delegate asynchronously like we did in r268097 is risky compatibility-wise.
This caused breakage in at least 2 client applications. While this can be dealt with on the client side,
it would be better to fix what r268097 was trying to fix without making the delegate call asynchronous.
The reason calling the delegate asynchronously is risky is because some view state may have time to get
reset by the time the client gets notified on the crash, potentially confusing the crash handling logic
in the client.

No new tests, covered by WKNavigation.ReloadRelatedViewsInProcessDidTerminate API test that is
still passing even though the delegate call is no longer asynchronous.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::commitProvisionalPage):
(WebKit::WebPageProxy::resetStateAfterProcessTermination):
(WebKit::WebPageProxy::dispatchProcessDidTerminate):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
(WebKit::WebProcessProxy::requestTermination):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r272989 r272990  
     12021-02-17  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r268097): Calling processDidTerminate delegate asynchronously is risky compatibility-wise
     4        https://bugs.webkit.org/show_bug.cgi?id=222011
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Calling processDidTerminate delegate asynchronously like we did in r268097 is risky compatibility-wise.
     9        This caused breakage in at least 2 client applications. While this can be dealt with on the client side,
     10        it would be better to fix what r268097 was trying to fix without making the delegate call asynchronous.
     11        The reason calling the delegate asynchronously is risky is because some view state may have time to get
     12        reset by the time the client gets notified on the crash, potentially confusing the crash handling logic
     13        in the client.
     14
     15        No new tests, covered by WKNavigation.ReloadRelatedViewsInProcessDidTerminate API test that is
     16        still passing even though the delegate call is no longer asynchronous.
     17
     18        * UIProcess/WebPageProxy.cpp:
     19        (WebKit::WebPageProxy::commitProvisionalPage):
     20        (WebKit::WebPageProxy::resetStateAfterProcessTermination):
     21        (WebKit::WebPageProxy::dispatchProcessDidTerminate):
     22        * UIProcess/WebPageProxy.h:
     23        * UIProcess/WebProcessProxy.cpp:
     24        (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
     25        (WebKit::WebProcessProxy::requestTermination):
     26
    1272021-02-17  Youenn Fablet  <youenn@apple.com>
    228
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r272925 r272990  
    33443344        send(Messages::WebPage::UnfreezeLayerTreeDueToSwipeAnimation());
    33453345
    3346     processDidTerminate(ProcessTerminationReason::NavigationSwap);
     3346    resetStateAfterProcessTermination(ProcessTerminationReason::NavigationSwap);
    33473347
    33483348    m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID);
     
    72387238}
    72397239
    7240 void WebPageProxy::processDidTerminate(ProcessTerminationReason reason)
     7240void WebPageProxy::resetStateAfterProcessTermination(ProcessTerminationReason reason)
    72417241{
    72427242    if (reason != ProcessTerminationReason::NavigationSwap)
     
    72657265    // If it does *during* process swapping, and the client triggers a reload, that causes bizarre WebKit re-entry.
    72667266    // FIXME: This might have to change
    7267     if (reason != ProcessTerminationReason::NavigationSwap) {
     7267    if (reason != ProcessTerminationReason::NavigationSwap)
    72687268        navigationState().clearAllNavigations();
    7269         dispatchProcessDidTerminate(reason);
    7270     }
    72717269
    72727270    if (m_controlledByAutomation) {
     
    73027300    RELEASE_LOG_ERROR_IF_ALLOWED(Loading, "dispatchProcessDidTerminate: reason = %d", reason);
    73037301
    7304     // We notify the client asynchronously because several pages may share the same process
    7305     // and we want to make sure all pages are aware their process has crashed before the
    7306     // the client reacts to the process termination.
    7307     RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this), reason] {
    7308         if (!weakThis)
    7309             return;
    7310 
    7311         bool handledByClient = false;
    7312         if (m_loaderClient)
    7313             handledByClient = reason != ProcessTerminationReason::RequestedByClient && m_loaderClient->processDidCrash(*this);
    7314         else
    7315             handledByClient = m_navigationClient->processDidTerminate(*this, reason);
    7316 
    7317         if (!handledByClient && shouldReloadAfterProcessTermination(reason))
    7318             tryReloadAfterProcessTermination();
    7319     });
     7302    bool handledByClient = false;
     7303    if (m_loaderClient)
     7304        handledByClient = reason != ProcessTerminationReason::RequestedByClient && m_loaderClient->processDidCrash(*this);
     7305    else
     7306        handledByClient = m_navigationClient->processDidTerminate(*this, reason);
     7307
     7308    if (!handledByClient && shouldReloadAfterProcessTermination(reason))
     7309        tryReloadAfterProcessTermination();
    73207310}
    73217311
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r272925 r272990  
    11771177    void processDidBecomeUnresponsive();
    11781178    void processDidBecomeResponsive();
    1179     void processDidTerminate(ProcessTerminationReason);
     1179    void resetStateAfterProcessTermination(ProcessTerminationReason);
    11801180    void provisionalProcessDidTerminate();
    11811181    void dispatchProcessDidTerminate(ProcessTerminationReason);
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r272550 r272990  
    886886
    887887    for (auto& page : pages)
    888         page->processDidTerminate(ProcessTerminationReason::Crash);
     888        page->resetStateAfterProcessTermination(ProcessTerminationReason::Crash);
    889889
    890890    for (auto& provisionalPage : provisionalPages) {
     
    892892            provisionalPage->processDidTerminate();
    893893    }
     894
     895    for (auto& page : pages)
     896        page->dispatchProcessDidTerminate(ProcessTerminationReason::Crash);
    894897
    895898    m_sleepDisablers.clear();
     
    12551258
    12561259    for (auto& page : pages)
    1257         page->processDidTerminate(reason);
     1260        page->resetStateAfterProcessTermination(reason);
    12581261       
    12591262    for (auto& provisionalPage : provisionalPages) {
     
    12611264            provisionalPage->processDidTerminate();
    12621265    }
     1266
     1267    for (auto& page : pages)
     1268        page->dispatchProcessDidTerminate(reason);
    12631269}
    12641270
Note: See TracChangeset for help on using the changeset viewer.