Title: [236662] trunk
Revision
236662
Author
you...@apple.com
Date
2018-10-01 09:17:29 -0700 (Mon, 01 Oct 2018)

Log Message

[macOS Sierra] Layout Test http/wpt/cache-storage/cache-put-keys.https.any.worker.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=184204

Reviewed by Chris Dumez.

Source/WebKit:

NetworkCache::Storage by default limits the length to read to 1500 milliseconds.
This is good for the HTTP cache since networking might be faster.
It does not work for DOM cache which needs to get these resources even if it takes a long time.

Since this is disabled by a Mode::Testing option, use it for DOMCache after renaming it to Mode::AvoidRandomness.

Add a bunch of release logging to help debugging error cases.

* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::retrieveOriginFromDirectory):
(WebKit::CacheStorage::Caches::initialize):
(WebKit::CacheStorage::Caches::writeCachesToDisk):
(WebKit::CacheStorage::Caches::readRecord):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::open):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::dispatchReadOperation):
(WebKit::NetworkCache::Storage::shrinkIfNeeded):
* NetworkProcess/cache/NetworkCacheStorage.h:

LayoutTests:

* platform/mac-wk2/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (236661 => 236662)


--- trunk/LayoutTests/ChangeLog	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/LayoutTests/ChangeLog	2018-10-01 16:17:29 UTC (rev 236662)
@@ -1,3 +1,12 @@
+2018-10-01  Youenn Fablet  <you...@apple.com>
+
+        [macOS Sierra] Layout Test http/wpt/cache-storage/cache-put-keys.https.any.worker.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=184204
+
+        Reviewed by Chris Dumez.
+
+        * platform/mac-wk2/TestExpectations:
+
 2018-10-01  Chris Dumez  <cdu...@apple.com>
 
         Make crossOriginObject.then undefined for promises

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (236661 => 236662)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-10-01 16:17:29 UTC (rev 236662)
@@ -876,8 +876,6 @@
 imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html [ Skip ]
 
-webkit.org/b/184204 [ Sierra ] http/wpt/cache-storage/cache-put-keys.https.any.worker.html [ Pass Failure ]
-
 webkit.org/b/189094 [ HighSierra+ ] accessibility/mac/focus-setting-selection-syncronizing-not-clearing.html [ Skip ]
 
 webkit.org/b/189598 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Pass Failure ]

Modified: trunk/Source/WebKit/ChangeLog (236661 => 236662)


--- trunk/Source/WebKit/ChangeLog	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/ChangeLog	2018-10-01 16:17:29 UTC (rev 236662)
@@ -1,3 +1,30 @@
+2018-10-01  Youenn Fablet  <you...@apple.com>
+
+        [macOS Sierra] Layout Test http/wpt/cache-storage/cache-put-keys.https.any.worker.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=184204
+
+        Reviewed by Chris Dumez.
+
+        NetworkCache::Storage by default limits the length to read to 1500 milliseconds.
+        This is good for the HTTP cache since networking might be faster.
+        It does not work for DOM cache which needs to get these resources even if it takes a long time.
+
+        Since this is disabled by a Mode::Testing option, use it for DOMCache after renaming it to Mode::AvoidRandomness.
+
+        Add a bunch of release logging to help debugging error cases.
+
+        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
+        (WebKit::CacheStorage::Caches::retrieveOriginFromDirectory):
+        (WebKit::CacheStorage::Caches::initialize):
+        (WebKit::CacheStorage::Caches::writeCachesToDisk):
+        (WebKit::CacheStorage::Caches::readRecord):
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::open):
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::dispatchReadOperation):
+        (WebKit::NetworkCache::Storage::shrinkIfNeeded):
+        * NetworkProcess/cache/NetworkCacheStorage.h:
+
 2018-10-01  Olivier Blin  <olivier.b...@softathome.com>
 
         [WPE] Remove WebKit2InspectorGResourceBundle.xml

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (236661 => 236662)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2018-10-01 16:17:29 UTC (rev 236662)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "CacheStorageEngine.h"
 
+#include "Logging.h"
 #include "NetworkCacheCoders.h"
 #include "NetworkCacheIOChannel.h"
 #include <WebCore/SecurityOrigin.h>
@@ -68,6 +69,7 @@
         channel->read(0, std::numeric_limits<size_t>::max(), nullptr, [completionHandler = WTFMove(completionHandler)](const Data& data, int error) mutable {
             ASSERT(RunLoop::isMain());
             if (error) {
+                RELEASE_LOG_ERROR(CacheStorage, "Caches::retrieveOriginFromDirectory failed reading channel with error %d", error);
                 completionHandler(std::nullopt);
                 return;
             }
@@ -138,8 +140,9 @@
         return;
     }
 
-    auto storage = Storage::open(m_rootPath, Storage::Mode::Normal);
+    auto storage = Storage::open(m_rootPath, Storage::Mode::AvoidRandomness);
     if (!storage) {
+        RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed opening storage");
         callback(Error::WriteDisk);
         return;
     }
@@ -150,6 +153,8 @@
 
     storeOrigin([this] (std::optional<Error>&& error) mutable {
         if (error) {
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed storing origin with error %d", *error);
+
             auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
             for (auto& callback : pendingCallbacks)
                 callback(Error::WriteDisk);
@@ -162,6 +167,8 @@
             makeDirty();
 
             if (!result.has_value()) {
+                RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed reading caches from disk with error %d", result.error());
+
                 auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
                 for (auto& callback : pendingCallbacks)
                     callback(result.error());
@@ -367,11 +374,8 @@
     return Data { encoder.buffer(), encoder.bufferSize() };
 }
 
-static inline Expected<Vector<std::pair<String, String>>, Error> decodeCachesNames(const Data& data, int error)
+static inline Expected<Vector<std::pair<String, String>>, Error> decodeCachesNames(const Data& data)
 {
-    if (error)
-        return makeUnexpected(Error::ReadDisk);
-
     WTF::Persistence::Decoder decoder(data.data(), data.size());
     uint64_t count;
     if (!decoder.decode(count))
@@ -415,8 +419,15 @@
             return;
         }
 
-        auto result = decodeCachesNames(data, error);
+        if (error) {
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::readCachesFromDisk failed reading caches from disk with error %d", error);
+            callback(makeUnexpected(Error::ReadDisk));
+            return;
+        }
+
+        auto result = decodeCachesNames(data);
         if (!result.has_value()) {
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::decodeCachesNames failed decoding caches with error %d", result.error());
             callback(makeUnexpected(result.error()));
             return;
         }
@@ -446,6 +457,9 @@
     m_isWritingCachesToDisk = true;
     m_engine->writeFile(cachesListFilename(m_rootPath), encodeCacheNames(m_caches), [this, protectedThis = makeRef(*this), callback = WTFMove(callback)](std::optional<Error>&& error) mutable {
         m_isWritingCachesToDisk = false;
+        if (error)
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::writeCachesToDisk failed writing caches to disk with error %d", *error);
+
         callback(WTFMove(error));
         while (!m_pendingWritingCachesToDiskCallbacks.isEmpty() && !m_isWritingCachesToDisk)
             m_pendingWritingCachesToDiskCallbacks.takeFirst()(std::nullopt);
@@ -509,6 +523,7 @@
 
     m_storage->retrieve(key, 4, [protectedStorage = makeRef(*m_storage), callback = WTFMove(callback)](std::unique_ptr<Storage::Record> storage, const Storage::Timings&) mutable {
         if (!storage) {
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::readRecord failed reading record from disk");
             callback(makeUnexpected(Error::ReadDisk));
             return false;
         }
@@ -515,6 +530,7 @@
 
         auto record = Cache::decode(*storage);
         if (!record) {
+            RELEASE_LOG_ERROR(CacheStorage, "Caches::readRecord failed decoding record from disk");
             callback(makeUnexpected(Error::ReadDisk));
             return false;
         }

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (236661 => 236662)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2018-10-01 16:17:29 UTC (rev 236662)
@@ -61,7 +61,7 @@
 
 RefPtr<Cache> Cache::open(const String& cachePath, OptionSet<Option> options)
 {
-    auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::Testing : Storage::Mode::Normal);
+    auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal);
 
     LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!storage);
 

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (236661 => 236662)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2018-10-01 16:17:29 UTC (rev 236662)
@@ -657,7 +657,7 @@
     ++m_readOperationDispatchCount;
 
     // Avoid randomness during testing.
-    if (m_mode != Mode::Testing) {
+    if (m_mode != Mode::AvoidRandomness) {
         // I/O pressure may make disk operations slow. If they start taking very long time we rather go to network.
         const Seconds readTimeout = 1500_ms;
         m_readOperationTimeoutTimer.startOneShot(readTimeout);
@@ -1070,7 +1070,7 @@
     ASSERT(RunLoop::isMain());
 
     // Avoid randomness caused by cache shrinks.
-    if (m_mode == Mode::Testing)
+    if (m_mode == Mode::AvoidRandomness)
         return;
 
     if (approximateSize() > m_capacity)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (236661 => 236662)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2018-10-01 16:17:29 UTC (rev 236662)
@@ -47,7 +47,7 @@
 
 class Storage : public ThreadSafeRefCounted<Storage> {
 public:
-    enum class Mode { Normal, Testing };
+    enum class Mode { Normal, AvoidRandomness };
     static RefPtr<Storage> open(const String& cachePath, Mode);
 
     struct Record {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to