Title: [228180] trunk/Source/WebCore
Revision
228180
Author
cdu...@apple.com
Date
2018-02-06 10:43:50 -0800 (Tue, 06 Feb 2018)

Log Message

Service workers registrations are saved to disk before the install / activation succeeds
https://bugs.webkit.org/show_bug.cgi?id=182535
<rdar://problem/36591485>

Reviewed by Youenn Fablet.

Service workers registrations are saved to disk before the install / activation succeeds.
This means if the browser exits before the install / activation succeeds, we may restore
from disk a registration with an “active” worker which may have never been installed /
activated.

To address the issue, we now delay saving the registration to disk until after the service
worker has been activated.

No new tests, restoration from disk is covered by API tests that still pass.

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::didFinishActivation):
(WebCore::SWServer::installContextData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228179 => 228180)


--- trunk/Source/WebCore/ChangeLog	2018-02-06 18:41:13 UTC (rev 228179)
+++ trunk/Source/WebCore/ChangeLog	2018-02-06 18:43:50 UTC (rev 228180)
@@ -1,3 +1,25 @@
+2018-02-06  Chris Dumez  <cdu...@apple.com>
+
+        Service workers registrations are saved to disk before the install / activation succeeds
+        https://bugs.webkit.org/show_bug.cgi?id=182535
+        <rdar://problem/36591485>
+
+        Reviewed by Youenn Fablet.
+
+        Service workers registrations are saved to disk before the install / activation succeeds.
+        This means if the browser exits before the install / activation succeeds, we may restore
+        from disk a registration with an “active” worker which may have never been installed /
+        activated.
+
+        To address the issue, we now delay saving the registration to disk until after the service
+        worker has been activated.
+
+        No new tests, restoration from disk is covered by API tests that still pass.
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::didFinishActivation):
+        (WebCore::SWServer::installContextData):
+
 2018-02-06  Ms2ger  <ms2...@igalia.com>
 
         Initialize ImageBitmap::m_bitmapData in the constructor.

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (228179 => 228180)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2018-02-06 18:41:13 UTC (rev 228179)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2018-02-06 18:43:50 UTC (rev 228180)
@@ -401,8 +401,12 @@
 {
     RELEASE_LOG(ServiceWorker, "%p - SWServer::didFinishActivation: Finished activation for service worker %llu", this, worker.identifier().toUInt64());
 
-    if (auto* registration = getRegistration(worker.registrationKey()))
-        registration->didFinishActivation(worker.identifier());
+    auto* registration = getRegistration(worker.registrationKey());
+    if (!registration)
+        return;
+
+    m_registrationStore.updateRegistration(worker.contextData());
+    registration->didFinishActivation(worker.identifier());
 }
 
 // https://w3c.github.io/ServiceWorker/#clients-getall
@@ -532,8 +536,6 @@
             return;
     }
 
-    m_registrationStore.updateRegistration(data);
-
     auto* connection = SWServerToContextConnection::globalServerToContextConnection();
     ASSERT(connection);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to