Skip to content
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: crash when switching origins with emulation settings set #35466

Merged
merged 1 commit into from Aug 29, 2022

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Aug 26, 2022

Description of Change

Closes #35389.

When we force change origins, our debugger class (a subclass of content::DevToolsAgentHostClient) isn't aware of those changes unless we hook RenderFrameHostChanged. If we don't do this, some navigation lifecycle events {loadingFinished, dataReceived} emitted by the renderer are lost. We disconnect and reconnect the webcontents to the DevToolsAgentHost to prevent this from happening.

As of CL:3758294. this results in a DCHECK, since DevToolsAgentHost::DisconnectWebContents results in a call to UpdateDeviceEmulationState and host_ is nullptr. To fix this, we revert those state update calls to early returns.

Upstreamed at CL:3856525

Checklist

Release Notes

Notes: Fixed a crash when switching origins with emulation settings set.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/21-x-y PR should also be added to the "21-x-y" branch. labels Aug 26, 2022
@codebytere codebytere requested review from a team as code owners August 26, 2022 10:25
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Aug 26, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 27, 2022
@codebytere codebytere merged commit 4744674 into main Aug 29, 2022
@codebytere codebytere deleted the fix-emulation branch August 29, 2022 12:53
@release-clerk
Copy link

release-clerk bot commented Aug 29, 2022

Release Notes Persisted

Fixed a crash when switching origins with emulation settings set.

@trop
Copy link
Contributor

trop bot commented Aug 29, 2022

I have automatically backported this PR to "21-x-y", please check out #35488

@trop trop bot added in-flight/21-x-y merged/21-x-y PR was merged to the "21-x-y" branch. and removed target/21-x-y PR should also be added to the "21-x-y" branch. in-flight/21-x-y labels Aug 29, 2022
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/21-x-y PR was merged to the "21-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: using debugger's Emulation.setDeviceMetricsOverride and changing origins(?) crashes Electron 21
3 participants