WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
314583
[BFCache] CachedPage::restore() leaks cached frame state when focus restoration is skipped
https://bugs.webkit.org/show_bug.cgi?id=314583
Summary
[BFCache] CachedPage::restore() leaks cached frame state when focus restorati...
Basuke Suzuki
Reported
2026-05-11 14:41:36 PDT
CachedPage::restore() has an early-return at `if (!focusedOrMainFrame) return;` that bypasses the `clear()` call at the end of the function. The cached frame state (m_cachedMainFrame holding CachedFrames with documents/views) is never released, even though the cached page's data has already been transferred to the live page by `m_cachedMainFrame->open()`. This causes ~CachedPage to call `m_cachedMainFrame->destroy()` later. After the fix in
bug 314238
(which destroys child CachedFrames before checking m_document), destroy() now descends into child CachedFrames whose documents have already been resumed by open() (state = NotInBackForwardCache). The ASSERT at CachedFrame.cpp:291 ASSERT(document->backForwardCacheState() == Document::InBackForwardCache); then fires, and the subsequent destroy code path corrupts live document state (detachViewsAndDocumentLoader, detachFromPage, removeAllEventListeners), hanging the WebContent process. The early-return path is reached when `page.focusController().focusedOrMainFrame()` returns null, which happens for iframe-process BFCache restoration where the page's main frame is a RemoteFrame and there is no LocalFrame to focus. Fix: call `clear()` in the early-return branch to release the cached frame state, since `open()` has already done its work and the cached storage is no longer needed.
Attachments
Add attachment
proposed patch, testcase, etc.
Basuke Suzuki
Comment 1
2026-05-11 14:50:15 PDT
Tracked in
rdar://176824162
Basuke Suzuki
Comment 2
2026-05-11 16:05:46 PDT
<
rdar://problem/176824162
>
Basuke Suzuki
Comment 3
2026-05-11 16:06:15 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/64708
EWS
Comment 4
2026-05-11 17:45:13 PDT
Committed
313043@main
(11ea56301070): <
https://commits.webkit.org/313043@main
> Reviewed commits have been landed. Closing PR #64708 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug