Title: [229151] trunk
Revision
229151
Author
[email protected]
Date
2018-03-01 15:19:07 -0800 (Thu, 01 Mar 2018)

Log Message

LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=179248
<rdar://problem/35377756>

Patch by Youenn Fablet <[email protected]> on 2018-03-01
Reviewed by Chris Dumez.

Source/WebKit:

WebKitTestRunner is clearing caches for every test but there might still be some on-going cache activity due to a previous test.
In that case, the activity might try to open the Caches object at the same time the files are deleted by the clearing task.
If the new test is trying to open the same caches, it will also receive the same error, hence the console log message.

To fix that issue, we clear the initialization pending callbacks when clearing the caches.
This prevents the new test to receive the error since the new test should only start some cache activity after the cache clear task is done.
Made refactoring to append the first callback into the list of pending callbacks.

* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::initialize):
(WebKit::CacheStorage::Caches::initializeSize):
(WebKit::CacheStorage::Caches::clear):
* NetworkProcess/cache/CacheStorageEngineCaches.h:

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229150 => 229151)


--- trunk/LayoutTests/ChangeLog	2018-03-01 23:18:28 UTC (rev 229150)
+++ trunk/LayoutTests/ChangeLog	2018-03-01 23:19:07 UTC (rev 229151)
@@ -1,5 +1,15 @@
 2018-03-01  Youenn Fablet  <[email protected]>
 
+        LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=179248
+        <rdar://problem/35377756>
+
+        Reviewed by Chris Dumez.
+
+        * TestExpectations:
+
+2018-03-01  Youenn Fablet  <[email protected]>
+
         Add API test to validate setting of service worker and cache storage directories
         https://bugs.webkit.org/show_bug.cgi?id=182543
 

Modified: trunk/LayoutTests/TestExpectations (229150 => 229151)


--- trunk/LayoutTests/TestExpectations	2018-03-01 23:18:28 UTC (rev 229150)
+++ trunk/LayoutTests/TestExpectations	2018-03-01 23:19:07 UTC (rev 229151)
@@ -176,7 +176,6 @@
 # Different failure string each test run due to a random number being dumped in test output
 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-css-images.https.html [ Skip ]
 
-webkit.org/b/179248 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html [ Pass Failure ]
 imported/w3c/web-platform-tests/service-workers/service-worker/websocket.https.html [ Pass Failure ]
 
 webkit.org/b/181901 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-cors-xhr.https.html [ DumpJSConsoleLogInStdErr Pass Failure ]

Modified: trunk/Source/WebKit/ChangeLog (229150 => 229151)


--- trunk/Source/WebKit/ChangeLog	2018-03-01 23:18:28 UTC (rev 229150)
+++ trunk/Source/WebKit/ChangeLog	2018-03-01 23:19:07 UTC (rev 229151)
@@ -1,5 +1,27 @@
 2018-03-01  Youenn Fablet  <[email protected]>
 
+        LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=179248
+        <rdar://problem/35377756>
+
+        Reviewed by Chris Dumez.
+
+        WebKitTestRunner is clearing caches for every test but there might still be some on-going cache activity due to a previous test.
+        In that case, the activity might try to open the Caches object at the same time the files are deleted by the clearing task.
+        If the new test is trying to open the same caches, it will also receive the same error, hence the console log message.
+
+        To fix that issue, we clear the initialization pending callbacks when clearing the caches.
+        This prevents the new test to receive the error since the new test should only start some cache activity after the cache clear task is done.
+        Made refactoring to append the first callback into the list of pending callbacks.
+
+        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
+        (WebKit::CacheStorage::Caches::initialize):
+        (WebKit::CacheStorage::Caches::initializeSize):
+        (WebKit::CacheStorage::Caches::clear):
+        * NetworkProcess/cache/CacheStorageEngineCaches.h:
+
+2018-03-01  Youenn Fablet  <[email protected]>
+
         Add API test to validate setting of service worker and cache storage directories
         https://bugs.webkit.org/show_bug.cgi?id=182543
 

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (229150 => 229151)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2018-03-01 23:18:28 UTC (rev 229150)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2018-03-01 23:19:07 UTC (rev 229151)
@@ -144,13 +144,13 @@
         callback(Error::WriteDisk);
         return;
     }
+
+    m_pendingInitializationCallbacks.append(WTFMove(callback));
     m_storage = storage.releaseNonNull();
     m_storage->writeWithoutWaiting();
 
-    storeOrigin([this, callback = WTFMove(callback)] (std::optional<Error>&& error) mutable {
+    storeOrigin([this] (std::optional<Error>&& error) mutable {
         if (error) {
-            callback(Error::WriteDisk);
-
             auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
             for (auto& callback : pendingCallbacks)
                 callback(Error::WriteDisk);
@@ -159,12 +159,10 @@
             return;
         }
 
-        readCachesFromDisk([this, callback = WTFMove(callback)](Expected<Vector<Cache>, Error>&& result) mutable {
+        readCachesFromDisk([this](Expected<Vector<Cache>, Error>&& result) mutable {
             makeDirty();
 
             if (!result.has_value()) {
-                callback(result.error());
-
                 auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
                 for (auto& callback : pendingCallbacks)
                     callback(result.error());
@@ -174,16 +172,14 @@
             }
             m_caches = WTFMove(result.value());
 
-            initializeSize(WTFMove(callback));
+            initializeSize();
         });
     });
 }
 
-void Caches::initializeSize(WebCore::DOMCacheEngine::CompletionCallback&& callback)
+void Caches::initializeSize()
 {
     if (!m_storage) {
-        callback(Error::Internal);
-
         auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
         for (auto& callback : pendingCallbacks)
             callback(Error::Internal);
@@ -191,12 +187,10 @@
     }
 
     uint64_t size = 0;
-    m_storage->traverse({ }, 0, [protectedThis = makeRef(*this), this, protectedStorage = makeRef(*m_storage), callback = WTFMove(callback), size](const auto* storage, const auto& information) mutable {
+    m_storage->traverse({ }, 0, [protectedThis = makeRef(*this), this, protectedStorage = makeRef(*m_storage), size](const auto* storage, const auto& information) mutable {
         if (!storage) {
             m_size = size;
             m_isInitialized = true;
-            callback(std::nullopt);
-
             auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
             for (auto& callback : pendingCallbacks)
                 callback(std::nullopt);
@@ -225,6 +219,10 @@
         return;
     }
 
+    auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
+    for (auto& callback : pendingCallbacks)
+        callback(Error::Internal);
+
     if (m_engine)
         m_engine->removeFile(cachesListFilename(m_rootPath));
     if (m_storage) {

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h (229150 => 229151)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2018-03-01 23:18:28 UTC (rev 229150)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2018-03-01 23:19:07 UTC (rev 229151)
@@ -80,7 +80,7 @@
 private:
     Caches(Engine&, WebCore::ClientOrigin&&, String&& rootPath, uint64_t quota);
 
-    void initializeSize(WebCore::DOMCacheEngine::CompletionCallback&&);
+    void initializeSize();
     void readCachesFromDisk(WTF::Function<void(Expected<Vector<Cache>, WebCore::DOMCacheEngine::Error>&&)>&&);
     void writeCachesToDisk(WebCore::DOMCacheEngine::CompletionCallback&&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to