Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b9c4c45e974285ed779ea8f4db66787b5e2f21d6
      
https://github.com/WebKit/WebKit/commit/b9c4c45e974285ed779ea8f4db66787b5e2f21d6
  Author: Ben Nham <[email protected]>
  Date:   2024-11-10 (Sun, 10 Nov 2024)

  Changed paths:
    M Source/WebCore/workers/service/server/SWServer.h
    M Source/WebKit/NetworkProcess/NetworkProcess.cpp
    M Source/WebKit/NetworkProcess/NetworkProcess.h
    M Source/WebKit/NetworkProcess/NetworkProcess.messages.in
    M 
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
    M 
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
    M Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
    M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
    M Tools/MiniBrowser/mac/AppDelegate.m
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm

  Log Message:
  -----------
  Acquire background activity for service worker termination
https://bugs.webkit.org/show_bug.cgi?id=282319
rdar://138594750

Reviewed by Youenn Fablet.

We are seeing some spurious ExceededCPULimit kills of WebContent processes 
associated with
background tabs. It looks like what is happening is that the process is 
suspended, and then for
whatever reason we have to terminate a service worker (e.g. in the logs we 
have, ITP is deleting
data for an origin and causing the associated service worker to be 
unregistered). NetworkProcess
then asks WebProcess to terminate the service worker directly, but the 
termination request never
even starts since the WebProcess is suspended.

To fix this, make NetworkProcess ask the UIProcess to start a background 
activity for WebProcess
that hosts the service worker before terminating it.

To test this, fix the existing SuspendAndTerminateWorker test to make sure that 
the process is fully
suspended before terminating the service worker. This needed to be fixed to 
take in to account the
process assertion cache.

* Source/WebCore/workers/service/server/SWServer.h:
(WebCore::SWServer::runningOrTerminatingCount const):
* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::runningOrTerminatingServiceWorkerCountForTesting 
const):
* Source/WebKit/NetworkProcess/NetworkProcess.h:
* Source/WebKit/NetworkProcess/NetworkProcess.messages.in:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::terminateWorker):
(WebKit::WebSWServerToContextConnection::workerTerminated):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _runningOrTerminatingServiceWorkerCountForTesting:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::processHasUnresponseServiceWorker):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::runningOrTerminatingServiceWorkerCountForTesting):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::workerTerminated):
* Tools/MiniBrowser/mac/AppDelegate.m:
(-[BrowserAppDelegate persistentDataStore]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
((ServiceWorkers, SuspendAndTerminateWorker)):

Canonical link: https://commits.webkit.org/286417@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to