Skip to content

fix: crash on window.close() with webContents on blur#47933

Merged
codebytere merged 1 commit intomainfrom
inspectable-web-contents-possible-null
Aug 4, 2025
Merged

fix: crash on window.close() with webContents on blur#47933
codebytere merged 1 commit intomainfrom
inspectable-web-contents-possible-null

Conversation

@codebytere
Copy link
Member

@codebytere codebytere commented Aug 1, 2025

Description of Change

Closes #47830.

it's possible that inspectable_web_contents_ is null in some cases. In the above bug, the WebContentsView's webContents calls window.close(), which causes the "blur" event to be emitted on webContents. When the user handles the event in the callback, inspectable_web_contents_ can already be gone, as window.close() causes asynchronous destruction.

Checklist

Release Notes

Notes: Fixed a crash when calling some webContents functions after window.close().

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 1, 2025
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Aug 1, 2025
@codebytere codebytere changed the title fix: crash on window.close with WebContentsView on blur fix: crash on window.close() with webContents on blur Aug 1, 2025
@codebytere codebytere marked this pull request as draft August 1, 2025 14:42
@codebytere codebytere force-pushed the inspectable-web-contents-possible-null branch from 6d9ea37 to 9e7a36e Compare August 1, 2025 15:17
@codebytere codebytere marked this pull request as ready for review August 1, 2025 17:13
@codebytere codebytere requested a review from VerteDinde August 1, 2025 19:45
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Aug 2, 2025
@codebytere codebytere merged commit 4232ed2 into main Aug 4, 2025
57 checks passed
@codebytere codebytere deleted the inspectable-web-contents-possible-null branch August 4, 2025 08:35
@release-clerk
Copy link

release-clerk bot commented Aug 4, 2025

Release Notes Persisted

Fixed a crash when calling some webContents functions after window.close().

@trop
Copy link
Contributor

trop bot commented Aug 4, 2025

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

@trop trop bot added in-flight/38-x-y and removed target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 4, 2025
@trop
Copy link
Contributor

trop bot commented Aug 4, 2025

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

@trop
Copy link
Contributor

trop bot commented Aug 4, 2025

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

@trop trop bot added in-flight/36-x-y in-flight/37-x-y and removed target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. labels Aug 4, 2025
@trop trop bot added merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. and removed in-flight/37-x-y in-flight/38-x-y in-flight/36-x-y labels Aug 4, 2025
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
…7933)

fix: crash on window.close with WebContentsView on blur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/36-x-y PR was merged to the "36-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webContentsView.webContents.isDevToolsOpened() crashes

2 participants