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
|
|
@ -0,0 +1,41 @@
|
|||
// tests/main/windows/popup-renderer-recovery.test.ts
|
||||
// 팝업 렌더러가 죽으면 다시 불러온다(창이 살아 있어 다시 만들어지지 않으므로). 연속 크래시는 반복하지 않는다.
|
||||
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { BrowserWindow } from 'electron'
|
||||
import {
|
||||
POPUP_RENDERER_RELOAD_INTERVAL_MS,
|
||||
recoverPopupRenderer,
|
||||
} from '../../../src/main/windows/popup-window-factory'
|
||||
|
||||
function fakeWindow(): { win: BrowserWindow; reload: ReturnType<typeof vi.fn> } {
|
||||
const reload = vi.fn()
|
||||
const win = {
|
||||
isDestroyed: () => false,
|
||||
webContents: { isDestroyed: () => false, reload },
|
||||
} as unknown as BrowserWindow
|
||||
return { win, reload }
|
||||
}
|
||||
|
||||
describe('recoverPopupRenderer', () => {
|
||||
it('크래시면 렌더러를 다시 불러온다', () => {
|
||||
const { win, reload } = fakeWindow()
|
||||
expect(recoverPopupRenderer(win, 'tip', 'crashed', 1_000)).toBe(true)
|
||||
expect(reload).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('정상 종료·강제 종료(앱 종료 중)는 다시 불러오지 않는다', () => {
|
||||
const { win, reload } = fakeWindow()
|
||||
expect(recoverPopupRenderer(win, 'tip', 'clean-exit', 1_000)).toBe(false)
|
||||
expect(recoverPopupRenderer(win, 'tip', 'killed', 1_000)).toBe(false)
|
||||
expect(reload).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('간격 안에 또 죽으면 다시 불러오지 않고, 간격이 지나면 다시 불러온다', () => {
|
||||
const { win, reload } = fakeWindow()
|
||||
recoverPopupRenderer(win, 'tip', 'oom', 1_000)
|
||||
expect(recoverPopupRenderer(win, 'tip', 'oom', 1_000 + POPUP_RENDERER_RELOAD_INTERVAL_MS - 1)).toBe(false)
|
||||
expect(recoverPopupRenderer(win, 'tip', 'oom', 1_000 + POPUP_RENDERER_RELOAD_INTERVAL_MS)).toBe(true)
|
||||
expect(reload).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue