[Site Isolation] Fix WKNavigation.LeakCheck#61299
Open
szewai wants to merge 1 commit intoWebKit:mainfrom
Open
Conversation
https://bugs.webkit.org/show_bug.cgi?id=310670 rdar://173275669 Reviewed by NOBODY (OOPS!). The test WKNavigation.LeakCheck tries to verify `WKNavigation` or `API::Navigation` will be destroyed when it is not in use, and here is the flow: 1. Create a WKWebView and loads "example.com" in it => This navigation creates first `WKNavigation` object. 2. Load "webkit.org" in the view => This navigation creates a second `WKNavigation` object. 3. Clear backforward cache. 4. Wait until the first `WKNavigation` object is destroyed. The test is currently timed out under Site Isolation because the `WKNavigation` object is never destroyed. The idea behind the test is (see 264449@main): if a page (`WebPageProxy`, including its `SuspendededPageProxy` and `ProvisionalPageProxy`) stops using a web process (`WebProcessProxy`), it should clear all navigation objects related to that process (`WebProcessProxy::reportProcessDisassociatedWithPageIfNecessary`). Under Site Isolation, backforward cache is currently disabled, so the page should be stop using the web process for "example.com" after navigation, and the navigation object should be destroyed; i.e. the test is still expected to pass. It turns out to be a bug in `WebProcessProxy::removeWebPage`. So `reportProcessDisassociatedWithPageIfNecessary` is responsible for notifying `WebPageProxy` about process is no longer in use, and `WebPageProxy` will go ahead to update navigation state (`WebNavigationState`), which leads to destruction of `WKNavigation` object. In `removeWebPage`, `reportProcessDisassociatedWithPageIfNecessary` is invoked after page is removed from `globalPageMap()`, so it cannot find the corresponding page for notificaiton, and the update on navigation state never happens (navigation object is not destroyed). To fix this, moving invocation of `reportProcessDisassociatedWithPageIfNecessary` to before the removal on `globalPageMap()`. This patch also adds a new dedicated test for this bug. Test: WKNavigation.LeakCheckNoPageCache * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::removeWebPage): * Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: (runNavigationLeakCheck): (TEST(WKNavigation, LeakCheck)): (TEST(WKNavigation, LeakCheckNoPageCache)):
Collaborator
|
EWS run on current version of this PR (hash f6d9b6f) Details
|
pvollan
approved these changes
Mar 25, 2026
pvollan
reviewed
Mar 25, 2026
| @@ -4351,24 +4352,27 @@ HTTPServer httpServer({ | |||
| EXPECT_WK_STREQ(@"", [webView URL].absoluteString); | |||
| } | |||
|
|
|||
| TEST(WKNavigation, LeakCheck) | |||
| enum class ShouldEnablePageCache : bool { No, Yes }; | |||
Contributor
There was a problem hiding this comment.
Nit: should we use ShouldEnableBackForwardCache?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 mac-apple
f6d9b6f
f6d9b6f