Changeset 251672 in webkit


Ignore:
Timestamp:
Oct 28, 2019 2:38:26 PM (5 years ago)
Author:
Kate Cheney
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:
Location:
trunk/Source/WebKit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r251665 r251672  
     12019-10-28  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Layout Test http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html is a flaky failure
     4        https://bugs.webkit.org/show_bug.cgi?id=203491
     5        <rdar://problem/56674176>
     6
     7        Reviewed by Chris Dumez.
     8
     9        No new tests, this change is tested by the existing resourceLoadStatistics
     10        tests.
     11
     12        This test started flaking when a new memory store was being created
     13        between tests to maintain consistency. The call to grandfatherExistingWebsiteData
     14        from populateMemoryStoreFromDisk in the persistent storage was
     15        async, causing a race condition that led to occasional failures.
     16        Adding a completion handler and changing the callsite of
     17        populateMemoryStoreFromDisk should fix this problem.
     18
     19        * NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp:
     20        (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
     21        * NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h:
     22        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     23        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
     24        The persistent store in the databaseEnabled case was never being used
     25        and is unnecessary.
     26
     27        (WebKit::WebResourceLoadStatisticsStore::populateMemoryStoreFromDisk):
     28        Since persistent storage only exists when using the memory store,
     29        populateMemoryStoreFromDisk should check if
     30        m_persistentStorage has been initialized.
     31
     32        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     33        * NetworkProcess/NetworkProcess.cpp:
     34        (WebKit::NetworkProcess::setUseITPDatabase):
     35        * NetworkProcess/NetworkSession.cpp:
     36        (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
     37        (WebKit::NetworkSession::recreateResourceLoadStatisticStore):
     38        * NetworkProcess/NetworkSession.h:
     39
    1402019-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
    241
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp

    r249313 r251672  
    6565    m_memoryStore.setPersistentStorage(*this);
    6666
    67     populateMemoryStoreFromDisk();
    6867    startMonitoringDisk();
    6968}
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h

    r249313 r251672  
    5555    enum class ForceImmediateWrite { No, Yes, };
    5656    void scheduleOrWriteMemoryStore(ForceImmediateWrite);
     57    void populateMemoryStoreFromDisk();
    5758
    5859private:
     
    6566
    6667    void writeMemoryStoreToDisk();
    67     void populateMemoryStoreFromDisk();
    6868    void excludeFromBackup() const;
    6969    void refreshMemoryStoreFromDisk();
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r251663 r251672  
    163163
    164164            auto memoryStore = makeUnique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue, shouldIncludeLocalhost);
    165             auto persistentStore = makeUnique<ResourceLoadStatisticsPersistentStorage>(*memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
    166 
    167165            downcast<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore.get()).populateFromMemoryStore(*memoryStore);
    168166        } else {
     
    222220    });
    223221    semaphore.wait();
     222}
     223
     224void WebResourceLoadStatisticsStore::populateMemoryStoreFromDisk(CompletionHandler<void()>&& completionHandler)
     225{
     226    ASSERT(RunLoop::isMain());
     227   
     228    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
     229        if (m_persistentStorage)
     230            m_persistentStorage->populateMemoryStoreFromDisk();
     231
     232        postTaskReply(WTFMove(completionHandler));
     233    });
    224234}
    225235
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r251663 r251672  
    107107    WTF::WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
    108108
     109    void populateMemoryStoreFromDisk(CompletionHandler<void()>&&);
    109110    void setNotifyPagesWhenDataRecordsWereScanned(bool);
    110111    void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r251663 r251672  
    666666        if (m_isITPDatabaseEnabled != value) {
    667667            m_isITPDatabaseEnabled = value;
    668             networkSession->recreateResourceLoadStatisticStore();
    669         }
    670         completionHandler();
     668            networkSession->recreateResourceLoadStatisticStore(WTFMove(completionHandler));
     669        } else
     670            completionHandler();
    671671    } else {
    672672        ASSERT_NOT_REACHED();
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r251663 r251672  
    165165
    166166    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics);
     167    m_resourceLoadStatistics->populateMemoryStoreFromDisk([] { });
    167168
    168169    if (m_enableResourceLoadStatisticsDebugMode == EnableResourceLoadStatisticsDebugMode::Yes)
     
    174175}
    175176
    176 void NetworkSession::recreateResourceLoadStatisticStore()
     177void NetworkSession::recreateResourceLoadStatisticStore(CompletionHandler<void()>&& completionHandler)
    177178{
    178179    destroyResourceLoadStatistics();
    179180    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics);
     181    m_resourceLoadStatistics->populateMemoryStoreFromDisk(WTFMove(completionHandler));
    180182}
    181183
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r251663 r251672  
    8585    WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
    8686    void setResourceLoadStatisticsEnabled(bool);
    87     void recreateResourceLoadStatisticStore();
     87    void recreateResourceLoadStatisticStore(CompletionHandler<void()>&&);
    8888    bool isResourceLoadStatisticsEnabled() const;
    8989    void notifyResourceLoadStatisticsProcessed();
Note: See TracChangeset for help on using the changeset viewer.