Changeset 253224 in webkit


Ignore:
Timestamp:
Dec 6, 2019 3:02:10 PM (4 years ago)
Author:
Chris Dumez
Message:

Reduce timeout for page to handle beforeunload events when trying to close a page
https://bugs.webkit.org/show_bug.cgi?id=204950
<rdar://problem/57700419>

Reviewed by Ryosuke Niwa.

Reduce timeout for page to handle beforeunload events when trying to close a page. It would previously
take up to 3 seconds to actually close a tab after the user would click on the "X" to close it. This
is because we would wait for the page to fire and handle the beforeunload events and only give up after
3 seconds. This patch reduces this timeout to something more reasonable from a user standpoint (500ms).

  • UIProcess/WebPageProxy.cpp:

(WebKit::m_tryCloseTimeoutTimer):
(WebKit::WebPageProxy::tryClose):
(WebKit::WebPageProxy::tryCloseTimedOut):
(WebKit::WebPageProxy::closePage):
(WebKit::m_resetRecentCrashCountTimer): Deleted.

  • UIProcess/WebPageProxy.h:
Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r253219 r253224  
     12019-12-06  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce timeout for page to handle beforeunload events when trying to close a page
     4        https://bugs.webkit.org/show_bug.cgi?id=204950
     5        <rdar://problem/57700419>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Reduce timeout for page to handle beforeunload events when trying to close a page. It would previously
     10        take up to 3 seconds to actually close a tab after the user would click on the "X" to close it. This
     11        is because we would wait for the page to fire and handle the beforeunload events and only give up after
     12        3 seconds. This patch reduces this timeout to something more reasonable from a user standpoint (500ms).
     13
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::m_tryCloseTimeoutTimer):
     16        (WebKit::WebPageProxy::tryClose):
     17        (WebKit::WebPageProxy::tryCloseTimedOut):
     18        (WebKit::WebPageProxy::closePage):
     19        (WebKit::m_resetRecentCrashCountTimer): Deleted.
     20        * UIProcess/WebPageProxy.h:
     21
    1222019-12-06  Jonathan Bedard  <jbedard@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r253195 r253224  
    272272static unsigned maximumWebProcessRelaunchAttempts = 1;
    273273static const Seconds audibleActivityClearDelay = 10_s;
     274static const Seconds tryCloseTimeoutDelay = 500_ms;
    274275
    275276namespace WebKit {
     
    450451#endif
    451452    , m_resetRecentCrashCountTimer(RunLoop::main(), this, &WebPageProxy::resetRecentCrashCount)
     453    , m_tryCloseTimeoutTimer(RunLoop::main(), this, &WebPageProxy::tryCloseTimedOut)
    452454{
    453455    RELEASE_LOG_IF_ALLOWED(Loading, "constructor:");
     
    10751077        return true;
    10761078
    1077     RELEASE_LOG_IF_ALLOWED(Loading, "tryClose:");
     1079    RELEASE_LOG_IF_ALLOWED(Process, "tryClose:");
    10781080
    10791081    // Close without delay if the process allows it. Our goal is to terminate
     
    10821084        return true;
    10831085
    1084     m_process->responsivenessTimer().start();
     1086    m_tryCloseTimeoutTimer.startOneShot(tryCloseTimeoutDelay);
    10851087    sendWithAsyncReply(Messages::WebPage::TryClose(), [this, weakThis = makeWeakPtr(*this)](bool shouldClose) {
    10861088        if (!weakThis)
    10871089            return;
    10881090
    1089         m_process->responsivenessTimer().stop();
     1091        m_tryCloseTimeoutTimer.stop();
    10901092        if (shouldClose)
    10911093            closePage();
    10921094    });
    10931095    return false;
     1096}
     1097
     1098void WebPageProxy::tryCloseTimedOut()
     1099{
     1100    RELEASE_LOG_ERROR_IF_ALLOWED(Process, "tryCloseTimedOut: Timed out waiting for the process to respond to the WebPage::TryClose IPC, closing the page now");
     1101    closePage();
    10941102}
    10951103
     
    53225330void WebPageProxy::closePage()
    53235331{
     5332    if (isClosed())
     5333        return;
     5334
     5335    RELEASE_LOG_IF_ALLOWED(Process, "closePage:");
    53245336    pageClient().clearAllEditCommands();
    53255337    m_uiClient->close(this);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r253187 r253224  
    21782178#endif
    21792179
     2180    void tryCloseTimedOut();
    21802181    void makeStorageSpaceRequest(WebCore::FrameIdentifier, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, CompletionHandler<void(uint64_t)>&&);
    21812182
     
    25952596    bool m_mayHaveUniversalFileReadSandboxExtension { false };
    25962597
     2598    RunLoop::Timer<WebPageProxy> m_tryCloseTimeoutTimer;
     2599
    25972600    std::unique_ptr<ProvisionalPageProxy> m_provisionalPage;
    25982601    std::unique_ptr<SuspendedPageProxy> m_suspendedPageKeptToPreventFlashing;
Note: See TracChangeset for help on using the changeset viewer.