Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b776e22550fb70e8942e2c34bfbbcb3798c72203
https://github.com/WebKit/WebKit/commit/b776e22550fb70e8942e2c34bfbbcb3798c72203
Author: Basuke Suzuki <[email protected]>
Date: 2026-05-20 (Wed, 20 May 2026)
Changed paths:
M Source/WebCore/history/BackForwardCache.cpp
M Source/WebCore/history/BackForwardCache.h
M Source/WebCore/history/CachedPage.h
M Source/WebCore/loader/FrameLoader.cpp
M Source/WebCore/loader/LocalFrameLoaderClient.cpp
M Source/WebCore/loader/LocalFrameLoaderClient.h
M Source/WebKit/UIProcess/WebBackForwardList.cpp
M Source/WebKit/UIProcess/WebBackForwardList.swift
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/WebPageProxy.messages.in
M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.h
Log Message:
-----------
[BFCache] Drive WebBackForwardCacheEntry lifecycle via explicit IPCs
https://bugs.webkit.org/show_bug.cgi?id=315104
rdar://177439386
Reviewed by Sihui Liu.
Replace the implicit BackForwardUpdateItem hasCachedPage flag relay with
three explicit IPCs:
- DidCacheItem(itemID) on successful addIfCacheable
- DidEvictCachedItem(itemID) on WP-side eviction (capacity / origin clear)
- DidRestoreFromBackForwardCache(itemID) on successful take
The hasCachedPage diff branch in WebBackForwardList::backForwardUpdateItem
(C++ and Swift) is removed. FrameState::hasCachedPage becomes unused —
removal deferred to a follow-up PR.
WebCore::CachedPage carries an optional BackForwardItemIdentifier so the
WP-side BFCache (frameItemID-keyed) can resolve a top-level itemID for the
client notifications. addIfCacheable(BackForwardFrameItemIdentifier, Page&)
takes itemID as an optional argument, bound at construction. Cross-site
WebPage::suspendForProcessSwap also passes itemID; the iframe SPP path
(suspendWithFrameItem) has no itemID context and omits it — those entries
are silent on eviction, matching their existing UIProcess flow through
SuspendedPageProxy.
Eviction notifications are funneled through notifyClientOfEviction, called
from remove(), prune(), and clearEntriesForOrigins(). The UI-rejection
rollback path (WebLocalFrameLoaderClient::didCacheItem failure handler)
calls remove() with ShouldNotifyClient::No to avoid bouncing
DidEvictCachedItem back to a UIProcess that never registered the entry.
Ordering note (FrameLoader.cpp): DidRestoreFromBackForwardCache fires
immediately after BackForwardCache::take() succeeds, before the
addIfCacheable / DidCacheItem block for the outgoing page in the same
commitProvisionalLoad. This matches the WebProcess BackForwardCache's
take→add order. Firing the restore IPC late inverts that order on the
UIProcess side and can drop a same-process sibling SuspendedPageProxy
entry as the new "oldest" entry under capacity pressure.
The new LocalFrameLoaderClient virtuals default to no-op so WebKitLegacy's
WebFrameLoaderClient — which has no UIProcess and tracks BFCache locally —
does not need to override them.
Covered by existing tests
(SiteIsolation.MultiProcessBFCacheSameSiteCaching,
MultiProcessBFCacheSameSiteWithCrossSiteIframeBlocked,
MultiProcessBFCacheSameSiteNavAfterRestore, MultiProcessBFCacheGoForward,
MultiProcessBFCacheGoForwardSimple, MultiProcessBFCacheIframeProcessSurvival,
MultiProcessBFCacheOpenerSkipsBFCache).
* Source/WebCore/history/BackForwardCache.h:
* Source/WebCore/history/BackForwardCache.cpp:
(WebCore::BackForwardCache::addIfCacheable):
(WebCore::notifyClientOfEviction):
(WebCore::BackForwardCache::remove):
(WebCore::BackForwardCache::prune):
(WebCore::BackForwardCache::clearEntriesForOrigins):
* Source/WebCore/history/CachedPage.h:
(WebCore::CachedPage::setItemID):
(WebCore::CachedPage::itemID const):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
* Source/WebCore/loader/LocalFrameLoaderClient.h:
* Source/WebCore/loader/LocalFrameLoaderClient.cpp:
(WebCore::LocalFrameLoaderClient::didCacheItem):
(WebCore::LocalFrameLoaderClient::didEvictItem):
(WebCore::LocalFrameLoaderClient::didRestoreFromBackForwardCache):
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::backForwardUpdateItem):
* Source/WebKit/UIProcess/WebBackForwardList.swift:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCacheItem):
(WebKit::WebPageProxy::didEvictCachedItem):
(WebKit::WebPageProxy::didRestoreFromBackForwardCache):
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::didCacheItem):
(WebKit::WebLocalFrameLoaderClient::didEvictItem):
(WebKit::WebLocalFrameLoaderClient::didRestoreFromBackForwardCache):
Canonical link: https://commits.webkit.org/313625@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications