Title: [255281] branches/safari-610.1.1-branch/Source/WebKit
Revision
255281
Author
[email protected]
Date
2020-01-28 13:48:50 -0800 (Tue, 28 Jan 2020)

Log Message

Cherry-pick r254706. rdar://problem/58183380

    Add finite timeout when synchronously terminating a service worker
    https://bugs.webkit.org/show_bug.cgi?id=206325
    <rdar://problem/58183380>

    Patch by Alex Christensen <[email protected]> on 2020-01-16
    Reviewed by Youenn Fablet.

    When this message reply is never received, it hangs everything.
    If we haven't received verification that a service worker was terminated in 10 seconds, unhang everything
    and tell the UI process to terminate the hanging service worker process. Continue handling messages during
    these 10 seconds to hopefully turn a bad hang into no perceptible hang.

    * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
    (WebKit::WebSWServerToContextConnection::syncTerminateWorker):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254706 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610.1.1-branch/Source/WebKit/ChangeLog (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/ChangeLog	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/ChangeLog	2020-01-28 21:48:50 UTC (rev 255281)
@@ -1,5 +1,42 @@
 2020-01-28  Russell Epstein  <[email protected]>
 
+        Cherry-pick r254706. rdar://problem/58183380
+
+    Add finite timeout when synchronously terminating a service worker
+    https://bugs.webkit.org/show_bug.cgi?id=206325
+    <rdar://problem/58183380>
+    
+    Patch by Alex Christensen <[email protected]> on 2020-01-16
+    Reviewed by Youenn Fablet.
+    
+    When this message reply is never received, it hangs everything.
+    If we haven't received verification that a service worker was terminated in 10 seconds, unhang everything
+    and tell the UI process to terminate the hanging service worker process. Continue handling messages during
+    these 10 seconds to hopefully turn a bad hang into no perceptible hang.
+    
+    * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
+    (WebKit::WebSWServerToContextConnection::syncTerminateWorker):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-01-16  Alex Christensen  <[email protected]>
+
+            Add finite timeout when synchronously terminating a service worker
+            https://bugs.webkit.org/show_bug.cgi?id=206325
+            <rdar://problem/58183380>
+
+            Reviewed by Youenn Fablet.
+
+            When this message reply is never received, it hangs everything.
+            If we haven't received verification that a service worker was terminated in 10 seconds, unhang everything
+            and tell the UI process to terminate the hanging service worker process. Continue handling messages during
+            these 10 seconds to hopefully turn a bad hang into no perceptible hang.
+
+            * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
+            (WebKit::WebSWServerToContextConnection::syncTerminateWorker):
+
+2020-01-28  Russell Epstein  <[email protected]>
+
         Cherry-pick r254552. rdar://problem/58536702
 
     REGRESSION (r253394): After swiping back during a navigation, WKWebView gets stuck with the forward content, stops repainting

Modified: branches/safari-610.1.1-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2020-01-28 21:48:50 UTC (rev 255281)
@@ -32,6 +32,7 @@
 #include "Logging.h"
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcess.h"
+#include "NetworkProcessProxyMessages.h"
 #include "ServiceWorkerFetchTask.h"
 #include "ServiceWorkerFetchTaskMessages.h"
 #include "WebCoreArgumentCoders.h"
@@ -107,7 +108,8 @@
 
 void WebSWServerToContextConnection::syncTerminateWorker(ServiceWorkerIdentifier serviceWorkerIdentifier)
 {
-    sendSync(Messages::WebSWContextManagerConnection::SyncTerminateWorker(serviceWorkerIdentifier), Messages::WebSWContextManagerConnection::SyncTerminateWorker::Reply());
+    if (!sendSync(Messages::WebSWContextManagerConnection::SyncTerminateWorker(serviceWorkerIdentifier), Messages::WebSWContextManagerConnection::SyncTerminateWorker::Reply(), 0, 10_s, IPC::SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply))
+        m_connection.networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::TerminateUnresponsiveServiceWorkerProcesses(registrableDomain(), m_connection.sessionID()), 0);
 }
 
 void WebSWServerToContextConnection::findClientByIdentifierCompleted(uint64_t requestIdentifier, const Optional<ServiceWorkerClientData>& data, bool hasSecurityError)

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-01-28 21:48:50 UTC (rev 255281)
@@ -424,6 +424,12 @@
     page->logDiagnosticMessage(message, description, shouldSample);
 }
 
+void NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses(WebCore::RegistrableDomain&& domain, PAL::SessionID sessionID)
+{
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->terminateServiceWorkerProcess(domain, sessionID);
+}
+
 void NetworkProcessProxy::logDiagnosticMessageWithResult(WebPageProxyIdentifier pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample shouldSample)
 {
     WebPageProxy* page = WebProcessProxy::webPage(pageID);

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-01-28 21:48:50 UTC (rev 255281)
@@ -174,6 +174,7 @@
     void didSyncAllCookies();
 
     void testProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebPageProxyIdentifier, Messages::NetworkProcessProxy::TestProcessIncomingSyncMessagesWhenWaitingForSyncReplyDelayedReply&&);
+    void terminateUnresponsiveServiceWorkerProcesses(WebCore::RegistrableDomain&&, PAL::SessionID);
 
     ProcessThrottler& throttler() { return m_throttler; }
     void updateProcessAssertion();

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-01-28 21:48:50 UTC (rev 255281)
@@ -30,6 +30,7 @@
     DidSyncAllCookies()
 
     TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebKit::WebPageProxyIdentifier pageID) -> (bool handled) Synchronous
+    TerminateUnresponsiveServiceWorkerProcesses(WebCore::RegistrableDomain domain, PAL::SessionID sessionId)
 
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
 

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-01-28 21:48:50 UTC (rev 255281)
@@ -1768,6 +1768,17 @@
 #endif
 }
 
+void WebProcessPool::terminateServiceWorkerProcess(const WebCore::RegistrableDomain& domain, const PAL::SessionID& sessionID)
+{
+#if ENABLE(SERVICE_WORKER)
+    auto protectedThis = makeRef(*this);
+    if (auto process = m_serviceWorkerProcesses.get({ domain, sessionID })) {
+        process->disableServiceWorkers();
+        process->requestTermination(ProcessTerminationReason::ExceededCPULimit);
+    }
+#endif
+}
+
 void WebProcessPool::syncNetworkProcessCookies()
 {
     ensureNetworkProcess().syncAllCookies();

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.h (255280 => 255281)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.h	2020-01-28 21:48:47 UTC (rev 255280)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/WebProcessPool.h	2020-01-28 21:48:50 UTC (rev 255281)
@@ -326,6 +326,7 @@
     void sendNetworkProcessWillSuspendImminentlyForTesting();
     void sendNetworkProcessDidResume();
     void terminateServiceWorkers();
+    void terminateServiceWorkerProcess(const WebCore::RegistrableDomain&, const PAL::SessionID&);
 
     void syncNetworkProcessCookies();
     void syncLocalStorage(CompletionHandler<void()>&& callback);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to