Title: [251598] trunk
Revision
251598
Author
you...@apple.com
Date
2019-10-25 12:04:27 -0700 (Fri, 25 Oct 2019)

Log Message

WebProcess should unregister its interest for a SWServerRegistration when all its corresponding ServiceWorkerRegistrations are destroyed
https://bugs.webkit.org/show_bug.cgi?id=203410

Reviewed by Chris Dumez.

Source/WebKit:

A SWServerRegistration is keeping a list of web processes that should be notified of change to its state.
Previously, WebProcesses were registering their interest to a SWServerRegistration on construction of a ServiceWorkerRegistration,
and unregistering their interest on destruction of a ServiceWorkerRegistration.

This does not work in case two ServiceWorkerRegistrations are created for the same SWServerRegistration in the same WebProcess.
In that case, when one of the two ServiceWorkerRegistration is destroyed, the WebProcess will no longer be notified of changes to the SWServerRegistration,
thus breaking the second ServiceWorkerRegistration behavior.

We introduce a map at WebProcess level to keep track of the number of ServiceWorkerRegistration created for a given SWServerRegistration.

Covered by re-enabled tests.

* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer):
(WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::addServiceWorkerRegistration):
(WebKit::WebProcess::removeServiceWorkerRegistration):
* WebProcess/WebProcess.h:

LayoutTests:

* platform/ios-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (251597 => 251598)


--- trunk/LayoutTests/ChangeLog	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/LayoutTests/ChangeLog	2019-10-25 19:04:27 UTC (rev 251598)
@@ -1,3 +1,13 @@
+2019-10-25  youenn fablet  <you...@apple.com>
+
+        WebProcess should unregister its interest for a SWServerRegistration when all its corresponding ServiceWorkerRegistrations are destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=203410
+
+        Reviewed by Chris Dumez.
+
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
 2019-10-25  Truitt Savell  <tsav...@apple.com>
 
         Followup test gardening after r251591

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (251597 => 251598)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2019-10-25 19:04:27 UTC (rev 251598)
@@ -1348,9 +1348,6 @@
 # <rdar://problem/52962272> fast/scrolling/ios/body-overflow-hidden.html is an Image failure
 fast/scrolling/ios/body-overflow-hidden.html [ Pass ImageOnlyFailure ]
 
-# <rdar://problem/56480245> REGRESSION (~r251067): http/tests/workers/service/registration-clear-redundant-worker.html is a flaky timeout (203218)
-webkit.org/b/203218 http/tests/workers/service/registration-clear-redundant-worker.html [ Pass Timeout ]
-
 # <rdar://problem/56506063> Layout Test imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html is a flaky failure (203256)
 webkit.org/b/203256 imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html [ Pass Failure ]
 

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (251597 => 251598)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-10-25 19:04:27 UTC (rev 251598)
@@ -929,9 +929,6 @@
 
 webkit.org/b/202500 [ Mojave ] crypto/workers/subtle/aes-indexeddb.html [ Timeout ]
 
-#<rdar://problem/56480245> REGRESSION (~r251067): http/tests/workers/service/registration-clear-redundant-worker.html is a flaky timeout (203218)
-webkit.org/b/203218 http/tests/workers/service/registration-clear-redundant-worker.html [ Pass Timeout ]
-
 # <rdar://problem/56506063> Layout Test imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html is a flaky failure (203256)
 webkit.org/b/203256 [ Debug ] imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html [ Pass Failure ]
 

Modified: trunk/Source/WebKit/ChangeLog (251597 => 251598)


--- trunk/Source/WebKit/ChangeLog	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/Source/WebKit/ChangeLog	2019-10-25 19:04:27 UTC (rev 251598)
@@ -1,5 +1,32 @@
 2019-10-25  youenn fablet  <you...@apple.com>
 
+        WebProcess should unregister its interest for a SWServerRegistration when all its corresponding ServiceWorkerRegistrations are destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=203410
+
+        Reviewed by Chris Dumez.
+
+        A SWServerRegistration is keeping a list of web processes that should be notified of change to its state.
+        Previously, WebProcesses were registering their interest to a SWServerRegistration on construction of a ServiceWorkerRegistration,
+        and unregistering their interest on destruction of a ServiceWorkerRegistration.
+
+        This does not work in case two ServiceWorkerRegistrations are created for the same SWServerRegistration in the same WebProcess.
+        In that case, when one of the two ServiceWorkerRegistration is destroyed, the WebProcess will no longer be notified of changes to the SWServerRegistration,
+        thus breaking the second ServiceWorkerRegistration behavior.
+
+        We introduce a map at WebProcess level to keep track of the number of ServiceWorkerRegistration created for a given SWServerRegistration.
+
+        Covered by re-enabled tests.
+
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer):
+        (WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::addServiceWorkerRegistration):
+        (WebKit::WebProcess::removeServiceWorkerRegistration):
+        * WebProcess/WebProcess.h:
+
+2019-10-25  youenn fablet  <you...@apple.com>
+
         mp4 video element broken with service worker
         https://bugs.webkit.org/show_bug.cgi?id=184447
         <rdar://problem/39313155>

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (251597 => 251598)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2019-10-25 19:04:27 UTC (rev 251598)
@@ -85,12 +85,15 @@
 
 void WebSWClientConnection::addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier identifier)
 {
+    // FIXME: We should send the message to network process only if this is a new registration, once we correctly handle recovery upon network process crash.
+    WebProcess::singleton().addServiceWorkerRegistration(identifier);
     send(Messages::WebSWServerConnection::AddServiceWorkerRegistrationInServer { identifier });
 }
 
 void WebSWClientConnection::removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier identifier)
 {
-    send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer { identifier });
+    if (WebProcess::singleton().removeServiceWorkerRegistration(identifier))
+        send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer { identifier });
 }
 
 void WebSWClientConnection::postMessageToServiceWorker(ServiceWorkerIdentifier destinationIdentifier, MessageWithMessagePorts&& message, const ServiceWorkerOrClientIdentifier& sourceIdentifier)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (251597 => 251598)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-10-25 19:04:27 UTC (rev 251598)
@@ -1757,6 +1757,16 @@
     ServiceWorkerProvider::singleton().registerServiceWorkerClients();
 }
 
+void WebProcess::addServiceWorkerRegistration(WebCore::ServiceWorkerRegistrationIdentifier identifier)
+{
+    m_swRegistrationCounts.add(identifier);
+}
+
+bool WebProcess::removeServiceWorkerRegistration(WebCore::ServiceWorkerRegistrationIdentifier identifier)
+{
+    ASSERT(m_swRegistrationCounts.contains(identifier));
+    return m_swRegistrationCounts.remove(identifier);
+}
 #endif
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (251597 => 251598)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2019-10-25 18:22:37 UTC (rev 251597)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2019-10-25 19:04:27 UTC (rev 251598)
@@ -48,11 +48,12 @@
 #if PLATFORM(MAC)
 #include <WebCore/ScreenProperties.h>
 #endif
+#include <WebCore/ServiceWorkerTypes.h>
 #include <WebCore/Timer.h>
 #include <pal/HysteresisActivity.h>
 #include <pal/SessionID.h>
 #include <wtf/Forward.h>
-#include <wtf/HashMap.h>
+#include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
 #include <wtf/RefCounter.h>
 #include <wtf/text/AtomString.h>
@@ -290,6 +291,11 @@
 
     void messagesAvailableForPort(const WebCore::MessagePortIdentifier&);
 
+#if ENABLE(SERVICE_WORKER)
+    void addServiceWorkerRegistration(WebCore::ServiceWorkerRegistrationIdentifier);
+    bool removeServiceWorkerRegistration(WebCore::ServiceWorkerRegistrationIdentifier);
+#endif
+
 private:
     WebProcess();
     ~WebProcess();
@@ -575,6 +581,10 @@
     float m_backlightLevel { 0 };
 #endif
 
+#if ENABLE(SERVICE_WORKER)
+    HashCountedSet<WebCore::ServiceWorkerRegistrationIdentifier> m_swRegistrationCounts;
+#endif
+
     HashMap<StorageAreaIdentifier, StorageAreaMap*> m_storageAreaMaps;
     
     // Prewarmed WebProcesses do not have an associated sessionID yet, which is why this is an optional.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to