我在渲染过程中使用process.crash()
或process.abort()
。
而且花了很长时间才收到崩溃事件。
这可能会导致不良的用户体验:
如果由于某种原因在渲染过程中发生崩溃,则用户需要在无响应的页面上等待很长时间(约20-30秒),并在很长一段时间后调用webContents.addListener('crashed'
的回调然后开发人员可以做些什么。
我搜索电子源代码并找到:
void WebContents::RenderProcessGone(base::TerminationStatus status) {
Emit("crashed", status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
这是向crashed
发出win.webContents
事件的正确函数吗?
也许与某些铬的加工有关
受我的知识水平的限制,我对此部分不太清楚。
const win = new BrowserWindow({
// some config...
});
win.webContents.addListener('crashed', () => {
// This callback is triggered too late
if (!win.isDestroyed()) {
win.close();
}
});
实际上,应用程序要复杂得多。
我想知道为什么从调用process.crash()
或process.abort()
到发出crashed
事件要花很长时间?在这段时间内电子或铬做了什么?
我想知道是否有解决此问题的解决方案(尽快获取crashed
事件)?