Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1bcdb2f2f2ebed2e4ca943b6db153135187c7ef2
https://github.com/WebKit/WebKit/commit/1bcdb2f2f2ebed2e4ca943b6db153135187c7ef2
Author: Chris Dumez <[email protected]>
Date: 2026-04-28 (Tue, 28 Apr 2026)
Changed paths:
M Source/WebCore/workers/service/server/SWRegistrationDatabase.cpp
M Source/WebCore/workers/service/server/SWRegistrationDatabase.h
M Source/WebCore/workers/service/server/SWRegistrationStore.h
M Source/WebCore/workers/service/server/SWServer.cpp
M Source/WebCore/workers/service/server/SWServer.h
M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
M Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
M Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h
M Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
M Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.cpp
M Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.h
M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp
M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp
M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h
M Source/WebKit/NetworkProcess/storage/ServiceWorkerStorageManager.cpp
M Source/WebKit/NetworkProcess/storage/ServiceWorkerStorageManager.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ServiceWorkerBasic.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebsiteDataStoreCustomPaths.mm
Log Message:
-----------
Import service worker registrations lazily, one top-level origin at a time
https://bugs.webkit.org/show_bug.cgi?id=313303
rdar://175432466
Reviewed by Youenn Fablet.
Previously, SWServer imported all service worker registrations from all origins
on
first navigation. For users with 1000+ registrations across many origins, this
took over 12
seconds and blocked all navigations because scheduleResourceLoad() and
matchRegistration()
waited for the full import to complete. Additionally, all operations shared the
same
serial work queue, so even a per-origin import dispatched alongside the bulk
import
would queue behind it. Nowadays, there is a service worker registrations
database
per origin that has service workers. This was a lot of databases to open and
query
during the first navigation.
This patch replaces the bulk import with a two-phase lazy approach:
1. On startup, a fast origin list logic populates the SWOriginStore so web
processes
can quickly reject origins without service workers. This relies on
checking if
cache folders for different origin have a service worker database or not.
This
takes ~700ms for > 1200 origins, which is a lot more manageable.
2. When registration data is actually needed for a specific origin
(navigation, fetch,
matchRegistration, push message, etc.), only that origin's registrations
are imported
from the database.
Since no bulk import occupies the serial work queue at startup, per-origin
imports
dispatch immediately.
* Source/WebCore/workers/service/server/SWRegistrationDatabase.cpp:
(WebCore::SWRegistrationDatabase::databaseFilePath):
(WebCore::SWRegistrationDatabase::statementString const):
(WebCore::SWRegistrationDatabase::importRegistrationsImpl):
(WebCore::SWRegistrationDatabase::importRegistrations):
(WebCore::SWRegistrationDatabase::collectRegistrationsFromStatement):
(WebCore::SWRegistrationDatabase::importOrigins):
(WebCore::databaseFilePath): Deleted.
* Source/WebCore/workers/service/server/SWRegistrationDatabase.h:
* Source/WebCore/workers/service/server/SWRegistrationStore.h:
* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::close):
(WebCore::SWServer::isImportCompletedForOrigin const):
(WebCore::SWServer::originImportComplete):
(WebCore::SWServer::importRegistrationsForOrigin):
(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clear):
(WebCore::SWServer::clearInternal):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::doRegistrationMatching):
(WebCore::SWServer::getOriginsWithRegistrations):
(WebCore::SWServer::performGetOriginsWithRegistrationsCallbacks):
(WebCore::SWServer::getAllOrigins):
(WebCore::SWServer::processPushMessage):
(WebCore::SWServer::processNotificationEvent):
(WebCore::SWServer::registrationStoreImportComplete): Deleted.
(WebCore::SWServer::whenImportIsCompleted): Deleted.
(WebCore::SWServer::whenImportIsCompletedIfNeeded): Deleted.
(WebCore::SWServer::registrationStoreDatabaseFailedToOpen): Deleted.
* Source/WebCore/workers/service/server/SWServer.h:
(WebCore::SWServer::isImportCompleted const): Deleted.
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.cpp:
(WebKit::WebSWRegistrationStore::importRegistrationsForOrigin):
(WebKit::WebSWRegistrationStore::importOriginList):
(WebKit::WebSWRegistrationStore::importRegistrations): Deleted.
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.h:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::resolveUnregistrationJobInClient):
* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::importServiceWorkerRegistrationsForOrigin):
(WebKit::NetworkStorageManager::importServiceWorkerOriginList):
(WebKit::NetworkStorageManager::importServiceWorkerRegistrations): Deleted.
* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:
* Source/WebKit/NetworkProcess/storage/ServiceWorkerStorageManager.cpp:
(WebKit::ServiceWorkerStorageManager::importRegistrations):
(WebKit::ServiceWorkerStorageManager::importOrigins):
* Source/WebKit/NetworkProcess/storage/ServiceWorkerStorageManager.h:
Canonical link: https://commits.webkit.org/312195@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications