Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Can't close browser window when detached devtools window is opened (electron 10) #25012
Comments
I'm unable to reproduce this issue with following steps:
Does this issue only happen within your app? |
Well. The quick-start application works for me too (updated to 10.0.0-beta.21) But my application still has that effect and, maybe it's related, the DOM element hightlighting does not work anymore in my app. Like when I hover over a node in the Elements view in inspect mode, there's no highlighting, no tooltips on the browser window. I try to replicate it now on the quick start by adding code that I use in my app one by one, checking if that cause the trouble but I'm pretty lost this time, as I don't really know which feature/API could potentially block the communication between browser window and devtools. Could be some electron code or it could also be an incompatible npm module. At least, it's on all of my browser windows, of which some have svelte apps and some (most) simply show web pages from our external intranet applications. So it's one thing all browser windows have in common or it's something with the general electron app setup. |
Found the issue - it's the custom-electron-titlebar which is not compatible with electron 10 and to make things worse, they just archived it so I need to fix it myself :/ To reproduce:
const {Color, Titlebar} = require("custom-electron-titlebar");
new Titlebar({
backgroundColor: Color.fromHex('#f5f5f5'),
unfocusEffect: false,
minimizable: true,
maximizable: true,
menu: null,
shadow: false,
}); Now, if we set Note that typing I can't tell if this is an incompatible 3rd party lib or if that lib reveals a bug in electron 10, so I keep this issue open. Unfortunately, this doesn't seem to be responsible for the 'highlight on hover' issue that I also have with electron 10. |
Finally I found the cause and it's an error in electron. This show the problem w/o a custom library. To reproduce:
const {remote} = require('electron');
function onFocus() {
console.log('dummy');
}
remote.getCurrentWindow().on('focus', onFocus);
window.addEventListener('beforeunload', () => {
// removing listeners from the browser window that we get via remote
// prevents closing the window only if the dev tools are shown.
remote.getCurrentWindow().removeListener('focus', onFocus);
})
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('closeButton').addEventListener('click', () => {
remote.getCurrentWindow().close();
})
}) Start the app, open the dev tools (any mode). Expected behavior: Observed behavior Hope that helps! |
Thanks for debugging this issue, I can confirm it is a bug of Electron. |
Also confirmed it is a Windows-only bug, it can be reproduced with this app: |
I may look into this, is that ok for you? |
So this is an issue only for the Windows OS or does this happen on other OS's as well? I wouldn't mind helping out if it's Windows only as I use Windows daily. Let me know. |
In case if you are handling the close in Windows may be below can help, const currentWindow = window.require('electron').remote.getCurrentWindow(); |
Wow. This is an excellent solution in a temporary development environment |
I am new to electron but have C++ and Java experience. Can I take this issue? |
Preflight Checklist
Issue Details
v10.0.0-beta.21
Windows 10 (1909)
v9.1.0
Expected Behavior
If I have a browser window and a detached devtools window for that opened, then I can close the browser window and the devtools window closes also.
Actual Behavior
I can't close the browser window. I have to manually close the detached devtools window first, then I can close the browser window.