fix(popups): reload a popup renderer after it crashes
The window survives a renderer crash, so the get*Window() getters never recreated it and the popup stayed blank until the app restarted (and a crashed suggestion overlay could still swallow clicks). On crashed, oom or abnormal-exit the ready flag is cleared and the renderer reloads, at most once per 30s so a renderer that keeps dying is not restarted in a loop.
This commit is contained in:
parent
ddd734fd30
commit
bdec40d8b7
2 changed files with 70 additions and 0 deletions
|
|
@ -120,9 +120,38 @@ function hookPopupDiagnostics(win: BrowserWindow, name: string): void {
|
|||
})
|
||||
win.webContents.on('render-process-gone', (_event, details) => {
|
||||
logger.error(`[${name}] renderer process gone: ${details.reason} (exitCode=${details.exitCode})`)
|
||||
recoverPopupRenderer(win, name, details.reason)
|
||||
})
|
||||
}
|
||||
|
||||
/** 팝업 렌더러가 죽은 뒤 다시 불러오는 최소 간격 — 곧바로 또 죽는 경우 재시작을 반복하지 않게 */
|
||||
export const POPUP_RENDERER_RELOAD_INTERVAL_MS = 30_000
|
||||
const lastPopupReloadAt = new WeakMap<BrowserWindow, number>()
|
||||
|
||||
/**
|
||||
* 창은 살아 있고 렌더러만 죽으면 get*Window() 가 창을 다시 만들지 않아, 재시작 전까지 팝업이 빈 창으로 남았다.
|
||||
* 준비 표시를 지우고(보낸 메시지는 다시 쌓인다) 렌더러를 다시 불러온다.
|
||||
*/
|
||||
export function recoverPopupRenderer(
|
||||
win: BrowserWindow,
|
||||
name: string,
|
||||
reason: string,
|
||||
now: number = Date.now(),
|
||||
): boolean {
|
||||
popupReady.delete(win)
|
||||
if (reason !== 'crashed' && reason !== 'oom' && reason !== 'abnormal-exit') return false
|
||||
if (win.isDestroyed() || win.webContents.isDestroyed()) return false
|
||||
const last = lastPopupReloadAt.get(win)
|
||||
if (last !== undefined && now - last < POPUP_RENDERER_RELOAD_INTERVAL_MS) {
|
||||
logger.warn(`[${name}] renderer crashed again within ${POPUP_RENDERER_RELOAD_INTERVAL_MS}ms — not reloading`)
|
||||
return false
|
||||
}
|
||||
lastPopupReloadAt.set(win, now)
|
||||
win.webContents.reload()
|
||||
logger.info(`[${name}] renderer reloaded after ${reason}`)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Deliver IPC to a popup even while its renderer is still loading.
|
||||
* webContents.send before load is silently dropped, which leaves popups stuck
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue