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

  Changed paths:
    M Source/WebKit/NetworkProcess/NetworkProcess.cpp
    M Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
    M Source/WebKit/NetworkProcess/cache/NetworkCache.h
    M Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
    M Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.h
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebsiteDataStoreCustomPaths.mm

  Log Message:
  -----------
  Network cache traversal decodes every record in full just to read its URL
https://bugs.webkit.org/show_bug.cgi?id=321234
rdar://184280149

Reviewed by Chris Dumez.

Cache::traverse decoded every visited record into an Entry before handing it to 
its client, and every client that
traverses only needs the response URL, to match the record against an origin or 
a registrable domain. Decoding an
Entry deserializes the whole ResourceResponse, so each record costs a full HTTP 
header map rebuild plus a SecTrust
deserialization, which DER-decodes and hashes the response's certificate chain, 
and this could be costly.

To reduce the cost, this patch adds Entry::decodeStorageRecordResponseURL, 
which only decodes URL from response and
stops there -- the Entry::encodeAsStorageRecord writes the response first, and 
Coder<WebCore::ResourceResponse> writes
m_isNull followed by m_url, so the URL is at the start of the record header and 
is decoded early.

Also, this patch adds assertion in decodeStorageRecord to ensure the decode URL 
is the same as Entry::response().url(),
so that reordering the coder's fields cannot silently turn the fast path into 
reading some other field as a URL.

Cache::traverse is replaced with Cache::traverseRecords, which hands out the 
undecoded Storage::Record and lets the
client decide what it needs, and convert the four clients that only need an 
origin.

One behavior difference: a record that failed to decode was previously skipped 
inside Cache::traverse, whichever field
failed. Now only a record whose URL cannot be decoded is skipped, so a record 
with a readable URL but a corrupt later
field becomes deletable, which seems more useful than keeping it around forever.

The new test WKWebsiteDataStore.RemoveDiskCacheDataForOrigin covers both 
directions of Cache::deleteData, that the
requested origin's entries are gone, and that another origin's entries are left 
alone.

* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteDataForOrigin):
* Source/WebKit/NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::traverseRecords):
(WebKit::NetworkCache::Cache::fetchData):
(WebKit::NetworkCache::Cache::deleteData):
(WebKit::NetworkCache::Cache::deleteDataForRegistrableDomains):
(WebKit::NetworkCache::Cache::traverse): Deleted.
* Source/WebKit/NetworkProcess/cache/NetworkCache.h:
* Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::decodeStorageRecord):
(WebKit::NetworkCache::Entry::decodeStorageRecordResponseURL):
* Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebsiteDataStoreCustomPaths.mm:
(TEST(WKWebsiteDataStore, RemoveDiskCacheDataForOrigin)):

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



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

Reply via email to