Title: [253224] trunk/Source/WebKit
Revision
253224
Author
[email protected]
Date
2019-12-06 15:02:10 -0800 (Fri, 06 Dec 2019)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (253223 => 253224)


--- trunk/Source/WebKit/ChangeLog	2019-12-06 23:01:30 UTC (rev 253223)
+++ trunk/Source/WebKit/ChangeLog	2019-12-06 23:02:10 UTC (rev 253224)
@@ -1,3 +1,24 @@
+2019-12-06  Chris Dumez  <[email protected]>
+
+        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:
+
 2019-12-06  Jonathan Bedard  <[email protected]>
 
         Python 3: Add support in webkitpy.test

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (253223 => 253224)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-12-06 23:01:30 UTC (rev 253223)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-12-06 23:02:10 UTC (rev 253224)
@@ -271,6 +271,7 @@
 static const Seconds resetRecentCrashCountDelay = 30_s;
 static unsigned maximumWebProcessRelaunchAttempts = 1;
 static const Seconds audibleActivityClearDelay = 10_s;
+static const Seconds tryCloseTimeoutDelay = 500_ms;
 
 namespace WebKit {
 using namespace WebCore;
@@ -449,6 +450,7 @@
     , m_inspectorDebuggable(makeUnique<WebPageDebuggable>(*this))
 #endif
     , m_resetRecentCrashCountTimer(RunLoop::main(), this, &WebPageProxy::resetRecentCrashCount)
+    , m_tryCloseTimeoutTimer(RunLoop::main(), this, &WebPageProxy::tryCloseTimedOut)
 {
     RELEASE_LOG_IF_ALLOWED(Loading, "constructor:");
 
@@ -1074,7 +1076,7 @@
     if (!hasRunningProcess())
         return true;
 
-    RELEASE_LOG_IF_ALLOWED(Loading, "tryClose:");
+    RELEASE_LOG_IF_ALLOWED(Process, "tryClose:");
 
     // Close without delay if the process allows it. Our goal is to terminate
     // the process, so we check a per-process status bit.
@@ -1081,12 +1083,12 @@
     if (m_process->isSuddenTerminationEnabled())
         return true;
 
-    m_process->responsivenessTimer().start();
+    m_tryCloseTimeoutTimer.startOneShot(tryCloseTimeoutDelay);
     sendWithAsyncReply(Messages::WebPage::TryClose(), [this, weakThis = makeWeakPtr(*this)](bool shouldClose) {
         if (!weakThis)
             return;
 
-        m_process->responsivenessTimer().stop();
+        m_tryCloseTimeoutTimer.stop();
         if (shouldClose)
             closePage();
     });
@@ -1093,6 +1095,12 @@
     return false;
 }
 
+void WebPageProxy::tryCloseTimedOut()
+{
+    RELEASE_LOG_ERROR_IF_ALLOWED(Process, "tryCloseTimedOut: Timed out waiting for the process to respond to the WebPage::TryClose IPC, closing the page now");
+    closePage();
+}
+
 void WebPageProxy::maybeInitializeSandboxExtensionHandle(WebProcessProxy& process, const URL& url, const URL& resourceDirectoryURL, SandboxExtension::Handle& sandboxExtensionHandle, bool checkAssumedReadAccessToResourceURL)
 {
     if (!url.isLocalFile())
@@ -5321,6 +5329,10 @@
 
 void WebPageProxy::closePage()
 {
+    if (isClosed())
+        return;
+
+    RELEASE_LOG_IF_ALLOWED(Process, "closePage:");
     pageClient().clearAllEditCommands();
     m_uiClient->close(this);
 }

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (253223 => 253224)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-12-06 23:01:30 UTC (rev 253223)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-12-06 23:02:10 UTC (rev 253224)
@@ -2177,6 +2177,7 @@
     void clearAudibleActivity();
 #endif
 
+    void tryCloseTimedOut();
     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)>&&);
 
     const Identifier m_identifier;
@@ -2594,6 +2595,8 @@
     bool m_needsFontAttributes { false };
     bool m_mayHaveUniversalFileReadSandboxExtension { false };
 
+    RunLoop::Timer<WebPageProxy> m_tryCloseTimeoutTimer;
+
     std::unique_ptr<ProvisionalPageProxy> m_provisionalPage;
     std::unique_ptr<SuspendedPageProxy> m_suspendedPageKeptToPreventFlashing;
     WeakPtr<SuspendedPageProxy> m_lastSuspendedPage;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to