Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7f8d70c0622228116a14f5100cf0e3e6fd333de7
      
https://github.com/WebKit/WebKit/commit/7f8d70c0622228116a14f5100cf0e3e6fd333de7
  Author: Sihui Liu <[email protected]>
  Date:   2026-08-06 (Thu, 06 Aug 2026)

  Changed paths:
    M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebsiteDataStoreCustomPaths.mm

  Log Message:
  -----------
  Web Extensions load with significant delay on iOS 26.6 when Safari is cold 
launched
https://bugs.webkit.org/show_bug.cgi?id=320812
rdar://183827503

Reviewed by Timothy Hatcher.

312231@main made WebExtensionContext::moveLocalStorageIfNeeded remove all 
website data for the previous base URL after
renaming localStorage and IndexedDB to the new one. A web extension gets a new 
base URL on every launch, so this runs
once per extension on every cold launch, with every website data type included. 
WebsiteDataType::DiskCache alone makes
NetworkCache::Cache::deleteData traverse the entire network cache, decoding 
every record's ResourceResponse on the
network process main thread. Other types also add their own launch-time cost: 
ScreenTime creates an STWebHistory XPC
connection on the UI process main thread, and DOMCache forces 
NetworkSession::ensureSWServer. Extension content
injection waits for all of it, because load() sets m_safeToInjectContent and 
calls addInjectedContent from
moveLocalStorageIfNeeded's completion handler.

This patch ensures to delete what the rename leaves behind as part of the 
rename instead.
NetworkStorageManager::moveData already calls 
removeOriginStorageManagerIfPossible for the source origin, which removes
the origin directory once it is empty, but it never became empty because only 
localStorage and IndexedDB were moved out
of it. Deleting the remaining managed types there makes that existing cleanup 
effective and lets WebExtensionContext
drop its separate removal entirely.

Partitions where the previous base URL is only one side of the ClientOrigin, 
along with MediaKeys and DeviceIdHashSalt,
are left to a follow-up that periodically removes data for extension origins 
that no longer belong to a loaded
extension: finding them requires traversing all origins, which that pass can do 
once instead of once per extension per
launch.

Test: WebKit.WebsiteDataStoreRenameOriginRemovesSourceOriginData

* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::moveData):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::moveLocalStorageIfNeeded):
(WebKit::WebExtensionContext::removeWebsiteDataForOrigin): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebsiteDataStoreCustomPaths.mm:
(displayNamesOfDataRecords):
(TEST(WebKit, WebsiteDataStoreRenameOriginRemovesSourceOriginData)):
(TEST(WebKit, NetworkCacheDirectory)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to