Skip to content
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: detect unresponsiveness and restart window #1909

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/webui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ const createWindow = () => {

window.webContents.on('unresponsive', event => {
logger.error(`[web ui] unresponsive: ${event.toString()}`)

let blocked = true
const unblock = () => {
logger.info('[web ui] recovered from unresponsiveness')
blocked = false
}

// Unblock the window in case it gets responsive within 10s.
window.webContents.once('responsive', unblock)

setTimeout(() => {
window.removeListener('responsive', unblock)
if (!blocked) {
return
}

// Destroy and restart window
logger.info('[web ui] unresponsive for 10s, will restart')
window.destroy()
// TODO: restart the window
}, 10000)
})

window.on('resize', () => {
Expand Down