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

feat: better handling of 'unresponsive' event #1952

Merged
merged 6 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,11 @@
"clearCustomIpfsBinarySuccess": {
"title": "Clear custom IPFS binary",
"message": "The custom IPFS binary was cleared. To start using the bundled IPFS version, IPFS needs to be restarted first."
},
"unresponsiveWindowDialog": {
"title": "IPFS Desktop became unresponsive",
"message": "Ongoing operation is taking more resources than expected. Do you wish to abort, and forcefully reload the interface?",
"forceReload": "Yes, reload",
"doNothing": "Do nothing"
}
}
24 changes: 20 additions & 4 deletions src/webui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ const { join } = require('path')
const { URL } = require('url')
const serve = require('electron-serve')
const os = require('os')
const i18n = require('i18next')
const openExternal = require('./open-external')
const logger = require('../common/logger')
const store = require('../common/store')
const dock = require('../utils/dock')
const { VERSION, ELECTRON_VERSION } = require('../common/consts')
const createToggler = require('../utils/create-toggler')
const { showDialog } = require('../dialogs')

serve({ scheme: 'webui', directory: join(__dirname, '../../assets/webui') })

Expand Down Expand Up @@ -38,12 +40,26 @@ const createWindow = () => {
window.webContents.openDevTools()
}

window.webContents.on('crashed', event => {
logger.error(`[web ui] crashed: ${event.toString()}`)
window.webContents.on('render-process-gone', (_, { reason, exitCode }) => {
logger.error(`[web ui] render-process-gone: ${reason}, code: ${exitCode}`)
})

window.webContents.on('unresponsive', event => {
logger.error(`[web ui] unresponsive: ${event.toString()}`)
window.webContents.on('unresponsive', async () => {
logger.error('[web ui] the webui became unresponsive')
Copy link
Member

@lidel lidel Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a dialog here, where user can decide if they want to kill a rogue webui process before it slows everything down to a crawl for some reason?

Found a poc here (just needs i18n strings):

contents.on('unresponsive', async () => {
  const { response } = await dialog.showMessageBox({
    message: 'App X has become unresponsive',
    title: 'Do you want to try forcefully reloading the app?',
    buttons: ['OK', 'Cancel'],
    cancelId: 1
  })
  if (response === 0) {
    contents.forcefullyCrashRenderer()
    contents.reload()
  }
})


const opt = showDialog({
title: i18n.t('unresponsiveWindowDialog.title'),
message: i18n.t('unresponsiveWindowDialog.message'),
buttons: [
i18n.t('unresponsiveWindowDialog.forceReload'),
i18n.t('unresponsiveWindowDialog.doNothing')
]
})

if (opt === 0) {
window.webContents.forcefullyCrashRenderer()
window.webContents.reload()
}
})

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