CDP: create an context per isolated world per frame - #3397
Open
karlseguin wants to merge 3 commits into
Open
Conversation
Previously, we created a single context per isolated world for the main frame. We now create an isolate world per frame. Fixes: #3347
Member
|
Does it impact #2400? |
Previously, we had a single root-bound context which we'd re-announce for every frame. Now, Page.createIsolatedWorld and addScriptToEvaluateOnNewDocument seed the context per frame(s).
karlseguin
marked this pull request as ready for review
September 4, 2026 03:03
Collaborator
Author
Yes, with the last commit, I believe both issues will be fixed. Worth pointing out that this will increase memory when iframes are loaded (for drivers that use this, which Puppeteer and Playwright do). |
| // This ensures CDP inspector contexts don't share v8::Globals with main world. | ||
| // Shared by all of the world's frame contexts, like the main world shares | ||
| // Page.identity across frames, and reset with them on root teardown. | ||
| identity: js.Identity = .{}, |
Member
There was a problem hiding this comment.
Isn't it a problem having multiple frame context sharing the same identity map?
Collaborator
Author
There was a problem hiding this comment.
No, this is why the identity map is stored on the page. Two frames in the same origin get the same v8::Object instance.
Collaborator
Author
There was a problem hiding this comment.
But that did make me realize that we don't give the context an origin, so it keeps its opaque origin and never gets the correct SecurityToken. That's fixed now.
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.
Previously, we created a single context per isolated world for the main frame. We now create an isolate world per frame.
Fixes: #3347 & #2400