Skip to content

fix: crash when switching origins with emulation settings set - #35466

Merged
codebytere merged 1 commit into
mainfrom
fix-emulation
Aug 29, 2022
Merged

fix: crash when switching origins with emulation settings set#35466
codebytere merged 1 commit into
mainfrom
fix-emulation

Conversation

@codebytere

@codebytere codebytere commented Aug 26, 2022

Copy link
Copy Markdown
Member

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 recently label Aug 26, 2022
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently 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

release-clerk Bot commented Aug 29, 2022

Copy link
Copy Markdown

Release Notes Persisted

Fixed a crash when switching origins with emulation settings set.

@trop

trop Bot commented Aug 29, 2022

Copy link
Copy Markdown
Contributor

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