-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
Async dialog API is slow to return on Linux #20533
Comments
After I noticed this today, and found this issue, I would like to confirm this bug for version Test script: $ cat test-slow-dialog.js
const { app, dialog } = require('electron');
app.on('ready', () => {
console.log('Before Dialog!');
let box = {
buttons: [ 'ok' ],
title: 'Title',
message: 'This is a message.'
}
let now = Date.now()
dialog
.showMessageBox(box)
.then(res => {
console.log('After promised dialog (%s ms)', Date.now() - now)
console.log(`Res: ${ JSON.stringify(res) }`)
return Date.now()
})
.then(now => {
let res = dialog.showMessageBoxSync(box)
console.log('After synchronous dialog (%s ms)', Date.now() - now)
console.log(`Res: ${ JSON.stringify(res) }`)
})
.catch(e => console.error(e))
.finally(() => app.quit())
}); Running the test:
Env:
|
Can confirm this issue on Windows too. Electron v12.0.0. It takes about 3 seconds for the promise to be returned. Sync version has no issue. I don't have this issue on messagebox though. |
I can't reproduce this on Windows under Electron v12.0.0:
|
I can reproduce it on Linux, though not consistently:
having a workaround: const { app, dialog } = require('electron');
app.on('ready', () => {
console.log('Before Dialog!');
let interval = setInterval(() => { /* nothing */ }, 100)
let box = {
buttons: [ 'ok' ],
title: 'Title',
message: 'This is a message.'
}
let now = Date.now()
dialog
.showMessageBox(box)
.then(res => {
clearInterval(interval)
console.log('After promised dialog (%s ms)', Date.now() - now)
console.log(`Res: ${ JSON.stringify(res) }`)
return Date.now()
})
.then(now => {
let res = dialog.showMessageBoxSync(box)
console.log('After synchronous dialog (%s ms)', Date.now() - now)
console.log(`Res: ${ JSON.stringify(res) }`)
})
.catch(e => console.error(e))
.finally(() => app.quit())
}); |
@nornagon as you said It's not consistent on Windows either. Works fine after a reboot most of the time. What I noticed is it's something related to Windows explorer because explorer sometimes crash or act buggy when I try this. Also the issue is only present for me on open/save dialogs. Probably caused by a Windows update. Async dialog API runs on a separate thread right? So under the hood it's still sync? |
@nornagon I suspect your conclusion - event loop problem - is right. I would test also something like setImmediate(() => {
dialog
.showMessageBox(box)
// ....
}) to research even more on the subject |
I bumped into a related issue today. I'm inexperienced with Electron so it took me quite a while to figure out what's going on. But my problem went away after applying the interval workaround so I'm assuming it's related. I'm calling After one or two repeated dialog opens, the render process just hangs. There's no error messages in the console and the devtools keep working, but the window freezes. The last time the dialog closes, the results are sent okay but they never arrive and the render window freezes. After finding this ticket, I tried adding no-op setInterval to the main process handler like in the workaround above -- and now my code works as it should. I'm running the latest Electron (17) on macOS 12.2.1. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment! |
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue. |
Preflight Checklist
Issue Details
When using async dialog API, the function takes several seconds to return.
This can be observed in
showSaveDialog
,showMessageBox
andshowOpenDialog
.v7.0.0-beta.6
v6.0.12
Ubuntu 19.04 x64
v5.0.11
Expected Behavior
There shouldn't be any added delay after user clicks on the dialog.
Actual Behavior
API only returns after several seconds after user clicked on a dialog option.
To Reproduce
Run the example code:
Observe the delay after clicking on "OK".
Screenshots
Bug reproduction screencast:
https://youtu.be/ZfiobQDvbOs
The text was updated successfully, but these errors were encountered: