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: BrowserView crash when 'beforeunload' prevented #37205

Merged
merged 1 commit into from Feb 14, 2023

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Feb 9, 2023

Description of Change

Closes #37162.
Refs #35509 & #36230

When Destroy() is called in WebContents::CloseContents instead of BrowserWindow::OnCloseContents, this leads to a crash when beforeunload is prevented in the renderer process instead and there is at least one BrowserView present. This is owing to the WebContents being nullptr in the BrowserView when it is called by NativeWindow::NonClientHitTest as a result of clicking the close button. This is fixed by moving the destroy call back to OnCloseContents so that BrowserViews are reset properly prior.

Tested with https://gist.github.com/YauheniBH-EF/190ea8ff42c09a15763705ed4647b02e

Checklist

Release Notes

Notes: Fixed a crash when BrowserViews are present and a user attempts to prevent beforeunload in the renderer process.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Feb 9, 2023
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/22-x-y PR should also be added to the "22-x-y" branch. target/23-x-y PR should also be added to the "23-x-y" branch. labels Feb 9, 2023
@jkleinsc jkleinsc added the target/24-x-y PR should also be added to the "24-x-y" branch. label Feb 9, 2023
@codebytere codebytere marked this pull request as draft February 9, 2023 15:40
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Feb 10, 2023
@codebytere codebytere force-pushed the browser-view-unload-crash branch 2 times, most recently from 5393b95 to 1a36853 Compare February 13, 2023 15:52
@codebytere codebytere marked this pull request as ready for review February 13, 2023 15:53
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Feb 13, 2023
@codebytere codebytere changed the title fix: crash when beforeunload prevented fix: BrowserView crash when 'beforeunload' prevented Feb 13, 2023
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Feb 14, 2023
@codebytere codebytere merged commit 8eee4f2 into main Feb 14, 2023
@codebytere codebytere deleted the browser-view-unload-crash branch February 14, 2023 17:40
@release-clerk
Copy link

release-clerk bot commented Feb 14, 2023

Release Notes Persisted

Fixed a crash when BrowserViews are present and a user attempts to prevent beforeunload in the renderer process.

@trop
Copy link
Contributor

trop bot commented Feb 14, 2023

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

@trop
Copy link
Contributor

trop bot commented Feb 14, 2023

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

@trop trop bot removed the target/22-x-y PR should also be added to the "22-x-y" branch. label Feb 14, 2023
@trop trop bot removed the target/23-x-y PR should also be added to the "23-x-y" branch. label Feb 14, 2023
@trop
Copy link
Contributor

trop bot commented Feb 14, 2023

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

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