-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix: cross-origin navigation disposing WebFrameMain instances #30076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cross-origin navigation disposing WebFrameMain instances #30076
Conversation
69c11b5
to
59d6132
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on samuelmaddock#1 as an approach though?
I added some thoughts just now to that PR. |
@samuelmaddock looks like lint is stuck, unfortunately the only way to fix this is to push to the branch. eg. |
71cf384
to
6346a6a
Compare
6346a6a
to
245d022
Compare
Rebased to latest |
Writing static method boilerplate isn't fun
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
I have automatically backported this PR to "14-x-y", please check out #30599 |
I have automatically backported this PR to "15-x-y", please check out #30600 |
@samuelmaddock This change breaks the |
We can close the backport PRs and revert this one. Then I'll follow up with a fixed PR. |
The issue seems to occur when electron/spec-main/api-protocol-spec.ts Lines 764 to 767 in 11de995
electron/shell/browser/api/electron_api_web_frame_main.cc Lines 183 to 198 in 11de995
|
Fix is to reset the mojo pipe when the RFH changes: void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
// Should only be called when swapping frames.
DCHECK(render_frame_);
render_frame_ = rfh;
+ renderer_api_.reset();
} |
Description of Change
Recommended reading to better understand RenderFrameHosts and swapping of them during cross-origin navigation:
https://www.chromium.org/developers/design-documents/oop-iframes
This PR is to address one of the issues brought up in #29290 (comment).
WebFrameMain
(WFM) currently abstractscontent::RenderFrameHost
and aligns closely with its lifespan. Under the OOPIF architecture and Site Isolation, cross-origin navigation leads to a RFH getting swapped for a new RFH in a separate process. WFM doesn't handle this case which will lead to cached references being marked as disposed if held through cross-origin navigation.To address this, I've modified lookup of a WFM instance to use a
FrameTreeNode
(FTN) ID. This is a globally unique ID associated with a FTN which indirectly owns a RFH.content::WebContentsObserver::RenderFrameHostChanged(old_host, new_host)
is invoked when a RFH is swapped during cross-origin navigation. By observing this event, we can update the internal RFH of a WFM instance if one exists.With WFM instances persisting through navigation, we can safely emit events for frame navigation in future work.
cc @nornagon
Checklist
npm test
passesRelease Notes
Notes: none