Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
34.0.0 or later
What operating system(s) are you using?
Windows
Operating System Version
Window 10 10.0.19045.5371
What arch are you using?
x64
Last Known Working Electron version
34.0.0 or later
Expected Behavior
The process should not be terminated even if the offscreen 'browserWindow' is closed.
ex)
const browserWindow = new BrowserWindow({ webPreferences: { offscreen: true } });
await browserWindow.loadURL('about:blank');
browserWindow.close(); // or browserWindow.webContents.executeJavaScript('window.close()');
const browserWindow2 = new BrowserWindow({ webPreferences: { offscreen: false } });
await browserWindow2.loadURL('about:blank');
Actual Behavior
Starting with 34.0.0, the process is unconditionally terminated when the offscreen 'browserWindow' is closed.
ex)
const browserWindow = new BrowserWindow({ webPreferences: { offscreen: true } });
await browserWindow.loadURL('about:blank');
browserWindow.close(); // or browserWindow.webContents.executeJavaScript('window.close()');
const browserWindow2 = new BrowserWindow({ webPreferences: { offscreen: false } });
await browserWindow2.loadURL('about:blank');
Testcase Gist URL
Additional Information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields👀 Unsorted Items
Activity
electron-issue-triage commentedon Feb 6, 2025
Hello @ntoskrnl7. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the blocked/need-reproNeeds a test case to reproduce the bug
label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.
ntoskrnl7 commentedon Feb 8, 2025
@nikwen
https://gist.github.com/ntoskrnl7/86f9aa5288e6b28794d317e97b011df1
nikwen commentedon Feb 10, 2025
The app quits because of this line in your gist:https://gist.github.com/ntoskrnl7/86f9aa5288e6b28794d317e97b011df1#file-main-js-L31After the first window is closed, it will execute thewindow-all-closedcallback because at that point all windows are closed. Change the behavior of that callback to not close the app and you'll achieve what you want to achieve.ntoskrnl7 commentedon Feb 10, 2025
@nikwen It has nothing to do with
window-all-closed.Because it only closes one offscreen window.
Have you tried removing the
window-all-closedpart and running your code?It seems like it's more important to fix the bug than to close the issue.
nikwen commentedon Feb 11, 2025
You are right. I ran the gist. The process crashes when
close()is called on the window.On Windows, it crashes with exit code
3221225477.On macOS, it crashes with the following message:
The code runs fine on Electron v33.4.0 and crashes on Electron v34.0.0+.