Changeset 271404 in webkit


Ignore:
Timestamp:
Jan 12, 2021 9:00:21 AM (3 years ago)
Author:
youenn@apple.com
Message:

Safari Networking high % CPU when Caches/WebKit/ServiceWorkers folder not writable
https://bugs.webkit.org/show_bug.cgi?id=220220
<rdar://problem/72930195>

Reviewed by Chris Dumez.

In case writing changes in the service worker database fails, we retry once.
If it fails, we give up and will only retry writing when new changes happen.
Manually tested.

  • workers/service/server/RegistrationDatabase.cpp:

(WebCore::RegistrationDatabase::pushChanges):
(WebCore::RegistrationDatabase::schedulePushChanges):

  • workers/service/server/RegistrationDatabase.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271402 r271404  
     12021-01-12  Youenn Fablet  <youenn@apple.com>
     2
     3        Safari Networking high % CPU when Caches/WebKit/ServiceWorkers folder not writable
     4        https://bugs.webkit.org/show_bug.cgi?id=220220
     5        <rdar://problem/72930195>
     6
     7        Reviewed by Chris Dumez.
     8
     9        In case writing changes in the service worker database fails, we retry once.
     10        If it fails, we give up and will only retry writing when new changes happen.
     11        Manually tested.
     12
     13        * workers/service/server/RegistrationDatabase.cpp:
     14        (WebCore::RegistrationDatabase::pushChanges):
     15        (WebCore::RegistrationDatabase::schedulePushChanges):
     16        * workers/service/server/RegistrationDatabase.h:
     17
    1182021-01-12  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp

    r265283 r271404  
    298298            removedRegistrations.append(keyValue.key.isolatedCopy());
    299299    }
    300     schedulePushChanges(WTFMove(updatedRegistrations), WTFMove(removedRegistrations), WTFMove(completionHandler));
    301 }
    302 
    303 void RegistrationDatabase::schedulePushChanges(Vector<ServiceWorkerContextData>&& updatedRegistrations, Vector<ServiceWorkerRegistrationKey>&& removedRegistrations, CompletionHandler<void()>&& completionHandler)
    304 {
    305     postTaskToWorkQueue([this, protectedThis = makeRef(*this), pushCounter = m_pushCounter, updatedRegistrations = WTFMove(updatedRegistrations), removedRegistrations = WTFMove(removedRegistrations), completionHandler = WTFMove(completionHandler)]() mutable {
     300    schedulePushChanges(WTFMove(updatedRegistrations), WTFMove(removedRegistrations), ShouldRetry::Yes, WTFMove(completionHandler));
     301}
     302
     303void RegistrationDatabase::schedulePushChanges(Vector<ServiceWorkerContextData>&& updatedRegistrations, Vector<ServiceWorkerRegistrationKey>&& removedRegistrations, ShouldRetry shouldRetry, CompletionHandler<void()>&& completionHandler)
     304{
     305    auto pushCounter = shouldRetry == ShouldRetry::Yes ? m_pushCounter : 0;
     306    postTaskToWorkQueue([this, protectedThis = makeRef(*this), pushCounter, updatedRegistrations = WTFMove(updatedRegistrations), removedRegistrations = WTFMove(removedRegistrations), completionHandler = WTFMove(completionHandler)]() mutable {
    306307        bool success = doPushChanges(updatedRegistrations, removedRegistrations);
    307308        if (success) {
     
    311312        callOnMainThread([this, protectedThis = WTFMove(protectedThis), success, pushCounter, updatedRegistrations = WTFMove(updatedRegistrations).isolatedCopy(), removedRegistrations = WTFMove(removedRegistrations).isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    312313            if (!success && (pushCounter + 1) == m_pushCounter) {
    313                 // We retry writing if no other change was pushed.
    314                 schedulePushChanges(WTFMove(updatedRegistrations), WTFMove(removedRegistrations), WTFMove(completionHandler));
     314                // We retry writing once if no other change was pushed.
     315                schedulePushChanges(WTFMove(updatedRegistrations), WTFMove(removedRegistrations), ShouldRetry::No, WTFMove(completionHandler));
    315316                return;
    316317            }
  • trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h

    r265283 r271404  
    6262    String databaseDirectoryIsolatedCopy() const { return m_databaseDirectory.isolatedCopy(); }
    6363
    64     void schedulePushChanges(Vector<ServiceWorkerContextData>&&, Vector<ServiceWorkerRegistrationKey>&&, CompletionHandler<void()>&&);
     64    enum class ShouldRetry { No, Yes };
     65    void schedulePushChanges(Vector<ServiceWorkerContextData>&&, Vector<ServiceWorkerRegistrationKey>&&, ShouldRetry, CompletionHandler<void()>&&);
    6566    void postTaskToWorkQueue(Function<void()>&&);
    6667
Note: See TracChangeset for help on using the changeset viewer.