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: getting focused window with destroyed webContents #33404
Conversation
23ad376
to
9656d8e
Compare
Thanks for the quick PR. |
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.
Can you rebase this PR? That should resolve the failing CI.
9656d8e
to
229ae03
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.
Code looks good to me.
229ae03
to
7b61c30
Compare
@codebytere Following up - can you speak to my comment above. Is this issue fixed when you call |
7b61c30
to
3bdbc21
Compare
@pushkin- yes - it should work both for closed and destroyed windows. I just added an extra safeguard, though, similar to what we have in our window test helpers |
Release Notes Persisted
|
I was unable to backport this PR to "16-x-y" cleanly; |
I was unable to backport this PR to "17-x-y" cleanly; |
I was unable to backport this PR to "18-x-y" cleanly; |
* fix: getting focused window with destroyed webContents * fix: add extra safeguards
/trop run backport-to 18-x-y |
The backport process for this PR has been manually initiated - sending your PR to |
I have automatically backported this PR to "18-x-y", please check out #33538 |
/trop run backport-to 17-x-y,16-x-y |
The backport process for this PR has been manually initiated - sending your PR to |
The backport process for this PR has been manually initiated - sending your PR to |
I have automatically backported this PR to "17-x-y", please check out #33539 |
I have automatically backported this PR to "16-x-y", please check out #33540 |
* fix: getting focused window with destroyed webContents * fix: add extra safeguards
* fix: getting focused window with destroyed webContents * fix: add extra safeguards
Description of Change
Closes #33326.
It's possible that
getFocusedWindow
could be called while a window is being destroyed or closed - if this is the case & its webContents is destroyed, a call to that method will result in anObject has been destroyed
error due toelectron/lib/browser/api/browser-window.ts
Line 75 in 77297f3
We fix this by ensuring that
getFocusedWindow
only includes windows with currently-alivewebContents
.Tested with https://gist.github.com/d7433e132a56679832f37a9446d4530c
Checklist
npm test
passesRelease Notes
Notes: Fixed a potential crash in
Browser.getFocusedWindow()
when child windows are closed.