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

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
    M Source/WebKit/UIProcess/WebsiteData/IsolatedSiteStore.cpp
    M Source/WebKit/UIProcess/WebsiteData/IsolatedSiteStore.h
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebsiteDatastore.mm

  Log Message:
  -----------
  [Site Isolation] Evict isolated sites once the store reaches its size cap
https://bugs.webkit.org/show_bug.cgi?id=321824
rdar://184964977

Reviewed by Ryosuke Niwa.

Every top-level visit records FirstPartyVisit, so IsolatedSiteStore could grow 
without bound. Cap it at 5000 entries,
which take roughly 600 KB in UIProcess and cover on the order of a year of 
first-party browsing. The number is a
judgment rather than a measurement, and may be adjusted once there is more data.

Eviction priority is decided by signal first and then by last updated time:
1. VisitOnly - FirstPartyVisit and nothing else
2. Gestured - the user also did something deliberate there
3. CredentialEvidence - anything outside firstPartySignals, evicted last

lastUpdated is rounded down to a day, so entries recorded on the same day 
cannot be ordered by it. Breaking that tie
by insertion order would make eviction depend on an implementation artifact 
rather than a meaningful signal - e.g. a
bulk import would always evict whichever half of the batch happened to be 
processed first, every time it ran. Ties
are broken at random instead, the same as WebProcessCache's and NetworkCache's 
eviction.

Since the steady state evicts a single entry per navigation, eviction targets 
are picked with nth_element rather than a
full sort. Candidates hold pointers to the keys in the table to avoid copying 
every domain, which is only safe because
nothing mutates m_sites between building the candidates and reading them back.

Eviction runs on the write path, and again after the load merges the rows from 
the database. The tracking prevention
import defers it until its batch finishes, so the imported set is capped in one 
pass rather than evicting entries as
each domain is added.

Split isolatedSiteRecordForDisplayName into isolatedSiteRecords so the new 
tests can count records directly, and hold
the returned array in a local rather than enumerating the temporary: 
Objective-C fast enumeration destroys temporaries
in the collection expression before the loop body runs, which would leave the 
enumeration walking a released array.

Tests: IsolatedSiteStore.EvictsOneOfTwoTiedSitesWithinTier
       IsolatedSiteStore.EvictsVisitOnlySiteBeforeGesturedSite
       IsolatedSiteStore.EvictionIsPersisted
       IsolatedSiteStore.EvictsLoadedSitesOverTheCap

* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _setMaximumIsolatedSiteCountForTesting:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* Source/WebKit/UIProcess/WebsiteData/IsolatedSiteStore.cpp:
(WebKit::IsolatedSiteStore::IsolatedSiteStore):
(WebKit::IsolatedSiteStore::didLoadSites):
(WebKit::IsolatedSiteStore::importUserInteractions):
(WebKit::IsolatedSiteStore::recordSignals):
(WebKit::IsolatedSiteStore::evictionTier):
(WebKit::IsolatedSiteStore::evictSitesIfNeeded):
(WebKit::IsolatedSiteStore::setMaximumSiteCountForTesting):
* Source/WebKit/UIProcess/WebsiteData/IsolatedSiteStore.h:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setMaximumIsolatedSiteCountForTesting):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebsiteDatastore.mm:
(TestWebKitAPI::(IsolatedSiteStore, EvictsOneOfTwoTiedSitesWithinTier)):
(TestWebKitAPI::(IsolatedSiteStore, EvictsVisitOnlySiteBeforeGesturedSite)):
(TestWebKitAPI::(IsolatedSiteStore, EvictionIsPersisted)):
(TestWebKitAPI::(IsolatedSiteStore, EvictsLoadedSitesOverTheCap)):

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



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

Reply via email to