Title: [251672] trunk/Source/WebKit
Revision
251672
Author
[email protected]
Date
2019-10-28 14:38:26 -0700 (Mon, 28 Oct 2019)

Log Message

Layout Test http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=203491
<rdar://problem/56674176>

Reviewed by Chris Dumez.

No new tests, this change is tested by the existing resourceLoadStatistics
tests.

This test started flaking when a new memory store was being created
between tests to maintain consistency. The call to grandfatherExistingWebsiteData
from populateMemoryStoreFromDisk in the persistent storage was
async, causing a race condition that led to occasional failures.
Adding a completion handler and changing the callsite of
populateMemoryStoreFromDisk should fix this problem.

* NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp:
(WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
* NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
The persistent store in the databaseEnabled case was never being used
and is unnecessary.

(WebKit::WebResourceLoadStatisticsStore::populateMemoryStoreFromDisk):
Since persistent storage only exists when using the memory store,
populateMemoryStoreFromDisk should check if
m_persistentStorage has been initialized.

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setUseITPDatabase):
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
(WebKit::NetworkSession::recreateResourceLoadStatisticStore):
* NetworkProcess/NetworkSession.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (251671 => 251672)


--- trunk/Source/WebKit/ChangeLog	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/ChangeLog	2019-10-28 21:38:26 UTC (rev 251672)
@@ -1,3 +1,42 @@
+2019-10-28  Kate Cheney  <[email protected]>
+
+        Layout Test http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=203491
+        <rdar://problem/56674176>
+
+        Reviewed by Chris Dumez.
+
+        No new tests, this change is tested by the existing resourceLoadStatistics
+        tests.
+
+        This test started flaking when a new memory store was being created
+        between tests to maintain consistency. The call to grandfatherExistingWebsiteData
+        from populateMemoryStoreFromDisk in the persistent storage was
+        async, causing a race condition that led to occasional failures.
+        Adding a completion handler and changing the callsite of
+        populateMemoryStoreFromDisk should fix this problem.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp:
+        (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
+        * NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h:
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+        The persistent store in the databaseEnabled case was never being used
+        and is unnecessary.
+
+        (WebKit::WebResourceLoadStatisticsStore::populateMemoryStoreFromDisk):
+        Since persistent storage only exists when using the memory store,
+        populateMemoryStoreFromDisk should check if
+        m_persistentStorage has been initialized.
+
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::setUseITPDatabase):
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
+        (WebKit::NetworkSession::recreateResourceLoadStatisticStore):
+        * NetworkProcess/NetworkSession.h:
+
 2019-10-28  Wenson Hsieh  <[email protected]>
 
         [iOS] 3 editing/pasteboard/smart-paste-paragraph-* tests are flaky

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp	2019-10-28 21:38:26 UTC (rev 251672)
@@ -64,7 +64,6 @@
 
     m_memoryStore.setPersistentStorage(*this);
 
-    populateMemoryStoreFromDisk();
     startMonitoringDisk();
 }
 

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h	2019-10-28 21:38:26 UTC (rev 251672)
@@ -54,6 +54,7 @@
 
     enum class ForceImmediateWrite { No, Yes, };
     void scheduleOrWriteMemoryStore(ForceImmediateWrite);
+    void populateMemoryStoreFromDisk();
 
 private:
     String storageDirectoryPathIsolatedCopy() const;
@@ -64,7 +65,6 @@
     void monitorDirectoryForNewStatistics();
 
     void writeMemoryStoreToDisk();
-    void populateMemoryStoreFromDisk();
     void excludeFromBackup() const;
     void refreshMemoryStoreFromDisk();
 

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-10-28 21:38:26 UTC (rev 251672)
@@ -162,8 +162,6 @@
             m_statisticsStore = makeUnique<ResourceLoadStatisticsDatabaseStore>(*this, m_statisticsQueue, shouldIncludeLocalhost, resourceLoadStatisticsDirectory, sessionID);
 
             auto memoryStore = makeUnique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue, shouldIncludeLocalhost);
-            auto persistentStore = makeUnique<ResourceLoadStatisticsPersistentStorage>(*memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
-
             downcast<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore.get()).populateFromMemoryStore(*memoryStore);
         } else {
             m_statisticsStore = makeUnique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue, shouldIncludeLocalhost);
@@ -223,6 +221,18 @@
     semaphore.wait();
 }
 
+void WebResourceLoadStatisticsStore::populateMemoryStoreFromDisk(CompletionHandler<void()>&& completionHandler)
+{
+    ASSERT(RunLoop::isMain());
+    
+    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
+        if (m_persistentStorage)
+            m_persistentStorage->populateMemoryStoreFromDisk();
+
+        postTaskReply(WTFMove(completionHandler));
+    });
+}
+
 void WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode(bool value, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-10-28 21:38:26 UTC (rev 251672)
@@ -106,6 +106,7 @@
 
     WTF::WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
 
+    void populateMemoryStoreFromDisk(CompletionHandler<void()>&&);
     void setNotifyPagesWhenDataRecordsWereScanned(bool);
     void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&);
     void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-10-28 21:38:26 UTC (rev 251672)
@@ -665,9 +665,9 @@
     if (auto* networkSession = this->networkSession(sessionID)) {
         if (m_isITPDatabaseEnabled != value) {
             m_isITPDatabaseEnabled = value;
-            networkSession->recreateResourceLoadStatisticStore();
-        }
-        completionHandler();
+            networkSession->recreateResourceLoadStatisticStore(WTFMove(completionHandler));
+        } else
+            completionHandler();
     } else {
         ASSERT_NOT_REACHED();
         completionHandler();

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-10-28 21:38:26 UTC (rev 251672)
@@ -164,6 +164,7 @@
         return;
 
     m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics);
+    m_resourceLoadStatistics->populateMemoryStoreFromDisk([] { });
 
     if (m_enableResourceLoadStatisticsDebugMode == EnableResourceLoadStatisticsDebugMode::Yes)
         m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(true, [] { });
@@ -173,10 +174,11 @@
     m_resourceLoadStatistics->setIsThirdPartyCookieBlockingEnabled(m_thirdPartyCookieBlockingEnabled);
 }
 
-void NetworkSession::recreateResourceLoadStatisticStore()
+void NetworkSession::recreateResourceLoadStatisticStore(CompletionHandler<void()>&& completionHandler)
 {
     destroyResourceLoadStatistics();
     m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics);
+    m_resourceLoadStatistics->populateMemoryStoreFromDisk(WTFMove(completionHandler));
 }
 
 bool NetworkSession::isResourceLoadStatisticsEnabled() const

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (251671 => 251672)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-10-28 21:13:57 UTC (rev 251671)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-10-28 21:38:26 UTC (rev 251672)
@@ -84,7 +84,7 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
     void setResourceLoadStatisticsEnabled(bool);
-    void recreateResourceLoadStatisticStore();
+    void recreateResourceLoadStatisticStore(CompletionHandler<void()>&&);
     bool isResourceLoadStatisticsEnabled() const;
     void notifyResourceLoadStatisticsProcessed();
     void deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, Vector<std::pair<WebCore::RegistrableDomain, WebsiteDataToRemove>>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to