Title: [255952] releases/WebKitGTK/webkit-2.28/Source
Revision
255952
Author
[email protected]
Date
2020-02-06 07:12:19 -0800 (Thu, 06 Feb 2020)

Log Message

Merge r255909 - ServiceWorkerProvider::registerServiceWorkerClients is no longer needed
https://bugs.webkit.org/show_bug.cgi?id=207193

Reviewed by Chris Dumez.

Source/WebCore:

registerServiceWorkerClients is no longer needed since we moved service worker handling to network process.
We no longer have to optimize creating a sw server connection since we piggy back on the webprocess to network process connection.

As can be seen from DocumentLoader, we register service worker clients in DocumentLoader::commitData.
The only documents we do not register are documents for which we exit early due to creatingInitialEmptyDocument check.

registerServiceWorkerClients was used initially when starting the first service worker process.
This is obsolete since now we split service workers according sessionID and registrable domains.

No observable change of behavior if network process does not crash.
Covered by existing service worker tests crashing network process in the middle of processing.

* workers/service/SWClientConnection.cpp:
(WebCore::SWClientConnection::registerServiceWorkerClients):
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerProvider.cpp:
* workers/service/ServiceWorkerProvider.h:

Source/WebKit:

Remove the request from WebProcessPool to register all service worker clients at launch of the first service worker process.
This is no longer needed and does not scale since our service workers are launched in different processes nowadays.

In case network process crashes, WebProcess will need to reregister their service worker clients.
This is lazily done when WebProcess tries to reconnect to the Network Process.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureNetworkProcessConnection):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog	2020-02-06 15:12:19 UTC (rev 255952)
@@ -1,3 +1,28 @@
+2020-02-06  youenn fablet  <[email protected]>
+
+        ServiceWorkerProvider::registerServiceWorkerClients is no longer needed
+        https://bugs.webkit.org/show_bug.cgi?id=207193
+
+        Reviewed by Chris Dumez.
+
+        registerServiceWorkerClients is no longer needed since we moved service worker handling to network process.
+        We no longer have to optimize creating a sw server connection since we piggy back on the webprocess to network process connection.
+
+        As can be seen from DocumentLoader, we register service worker clients in DocumentLoader::commitData.
+        The only documents we do not register are documents for which we exit early due to creatingInitialEmptyDocument check.
+
+        registerServiceWorkerClients was used initially when starting the first service worker process.
+        This is obsolete since now we split service workers according sessionID and registrable domains.
+
+        No observable change of behavior if network process does not crash.
+        Covered by existing service worker tests crashing network process in the middle of processing.
+
+        * workers/service/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::registerServiceWorkerClients):
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerProvider.cpp:
+        * workers/service/ServiceWorkerProvider.h:
+
 2020-02-05  David Kilzer  <[email protected]>
 
         Crash when printing at WebCore: WebCore::FrameView::paintContents

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.cpp (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.cpp	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.cpp	2020-02-06 15:12:19 UTC (rev 255952)
@@ -263,6 +263,14 @@
     }
 }
 
+void SWClientConnection::registerServiceWorkerClients()
+{
+    for (auto* document : Document::allDocuments()) {
+        auto controllingServiceWorkerRegistrationIdentifier = document->activeServiceWorker() ? makeOptional<ServiceWorkerRegistrationIdentifier>(document->activeServiceWorker()->registrationIdentifier()) : WTF::nullopt;
+        registerServiceWorkerClient(document->topOrigin(), ServiceWorkerClientData::from(*document, *this), controllingServiceWorkerRegistrationIdentifier, document->userAgent(document->url()));
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.h (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.h	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/SWClientConnection.h	2020-02-06 15:12:19 UTC (rev 255952)
@@ -87,6 +87,8 @@
     virtual void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback) { callback(); }
     virtual void isServiceWorkerRunning(ServiceWorkerIdentifier, CompletionHandler<void(bool)>&& callback) { callback(false); }
 
+    WEBCORE_EXPORT void registerServiceWorkerClients();
+
 protected:
     WEBCORE_EXPORT SWClientConnection();
 

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.cpp (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.cpp	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.cpp	2020-02-06 15:12:19 UTC (rev 255952)
@@ -55,17 +55,6 @@
     sharedProvider = &newProvider;
 }
 
-void ServiceWorkerProvider::registerServiceWorkerClients()
-{
-    setMayHaveRegisteredServiceWorkers();
-    for (auto* document : Document::allDocuments()) {
-        if (!document->page() || document->page()->mainFrame().loader().client().isServiceWorkerFrameLoaderClient())
-            continue;
-        if (LegacySchemeRegistry::canServiceWorkersHandleURLScheme(document->url().protocol().toStringWithoutCopying()))
-            document->setServiceWorkerConnection(&serviceWorkerConnection());
-    }
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.h (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.h	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/workers/service/ServiceWorkerProvider.h	2020-02-06 15:12:19 UTC (rev 255952)
@@ -42,8 +42,6 @@
 
     virtual SWClientConnection& serviceWorkerConnection() = 0;
 
-    void registerServiceWorkerClients();
-
     void setMayHaveRegisteredServiceWorkers() { m_mayHaveRegisteredServiceWorkers = true; }
 
 private:

Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog	2020-02-06 15:12:19 UTC (rev 255952)
@@ -1,3 +1,23 @@
+2020-02-06  youenn fablet  <[email protected]>
+
+        ServiceWorkerProvider::registerServiceWorkerClients is no longer needed
+        https://bugs.webkit.org/show_bug.cgi?id=207193
+
+        Reviewed by Chris Dumez.
+
+        Remove the request from WebProcessPool to register all service worker clients at launch of the first service worker process.
+        This is no longer needed and does not scale since our service workers are launched in different processes nowadays.
+
+        In case network process crashes, WebProcess will need to reregister their service worker clients.
+        This is lazily done when WebProcess tries to reconnect to the Network Process.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensureNetworkProcessConnection):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2020-02-05  Don Olmstead  <[email protected]>
 
         [PlayStation] Miscellaneous build fixes February 2020 edition

Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/WebProcessPool.cpp (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-02-06 15:12:19 UTC (rev 255952)
@@ -756,9 +756,6 @@
         return;
     }
 
-    if (m_serviceWorkerProcesses.isEmpty())
-        sendToAllProcesses(Messages::WebProcess::RegisterServiceWorkerClients { });
-
     WebProcessProxy* serviceWorkerProcessProxy { nullptr };
     if (!m_useSeparateServiceWorkerProcess) {
         for (auto& process : m_processes) {

Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.cpp (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.cpp	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.cpp	2020-02-06 15:12:19 UTC (rev 255952)
@@ -70,6 +70,7 @@
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxyMessages.h"
 #include "WebResourceLoadObserver.h"
+#include "WebSWClientConnection.h"
 #include "WebSWContextManagerConnection.h"
 #include "WebSWContextManagerConnectionMessages.h"
 #include "WebServiceWorkerProvider.h"
@@ -1202,6 +1203,11 @@
         m_networkProcessConnection->setNetworkProcessAuditToken(WTFMove(connectionInfo.auditToken));
 #endif
         m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::RegisterURLSchemesAsCORSEnabled(WebCore::LegacySchemeRegistry::allURLSchemesRegisteredAsCORSEnabled()), 0);
+
+#if ENABLE(SERVICE_WORKER)
+        if (!Document::allDocuments().isEmpty())
+            m_networkProcessConnection->serviceWorkerConnection().registerServiceWorkerClients();
+#endif
     }
     
     return *m_networkProcessConnection;
@@ -1860,11 +1866,6 @@
     SWContextManager::singleton().connection()->establishConnection(WTFMove(completionHandler));
 }
 
-void WebProcess::registerServiceWorkerClients()
-{
-    ServiceWorkerProvider::singleton().registerServiceWorkerClients();
-}
-
 void WebProcess::addServiceWorkerRegistration(WebCore::ServiceWorkerRegistrationIdentifier identifier)
 {
     m_swRegistrationCounts.add(identifier);

Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.h (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.h	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.h	2020-02-06 15:12:19 UTC (rev 255952)
@@ -401,7 +401,6 @@
 
 #if ENABLE(SERVICE_WORKER)
     void establishWorkerContextConnectionToNetworkProcess(uint64_t pageGroupID, WebPageProxyIdentifier, WebCore::PageIdentifier, const WebPreferencesStore&, WebCore::RegistrableDomain&&, ServiceWorkerInitializationData&&, CompletionHandler<void()>&&);
-    void registerServiceWorkerClients();
 #endif
 
     void fetchWebsiteData(OptionSet<WebsiteDataType>, CompletionHandler<void(WebsiteData&&)>&&);

Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.messages.in (255951 => 255952)


--- releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.messages.in	2020-02-06 15:12:12 UTC (rev 255951)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebProcess.messages.in	2020-02-06 15:12:19 UTC (rev 255952)
@@ -107,7 +107,6 @@
 
 #if ENABLE(SERVICE_WORKER)
     EstablishWorkerContextConnectionToNetworkProcess(uint64_t pageGroupID, WebKit::WebPageProxyIdentifier webPageProxyID, WebCore::PageIdentifier pageID, struct WebKit::WebPreferencesStore store, WebCore::RegistrableDomain domain, struct WebKit::ServiceWorkerInitializationData initializationData) -> () Async
-    RegisterServiceWorkerClients()
 #endif
 
     SetHasSuspendedPageProxy(bool hasSuspendedPageProxy);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to