gpt4 book ai didi

javascript - Electron 存在而不会发出 render-process-gone 事件

转载 作者:行者123 更新时间:2023-12-03 07:05:58 36 4
gpt4 key购买 nike

当我在 BrowserView 中加载的某个网站上按下按钮时, Electron 应用程序退出。这显然是一次崩溃,但它不会在 BrowserWindow(渲染器)或 BrowserView 上发出 render-process-gone。它只是退出。但是发出了 window-all-closed

app.on('ready', () => {
app.on('render-process-gone', (e, webContents, details) => {
console.log('render-process-gone', details);
});

const win = new BrowserWindow({
frame: false,
webPreferences: {
worldSafeExecuteJavaScript: true,
nodeIntegration: true,
webviewTag: false,
enableRemoteModule: false,
}
});

win.loadURL('file://' + __dirname + '/renderer.html');

const view = new BrowserView({
webPreferences: {
preload: 'preload.js'
worldSafeExecuteJavaScript: true,
nodeIntegration: false,
nodeIntegrationInSubFrames: true,
enableRemoteModule: false,
}
});

view.webContents.loadURL('http://website.com');

view.webContents.on('render-process-gone', (e, details) => {
console.log('render-process-gone', details);
});

win.setBrowserView(view);

});

app.on('window-all-closed', () => {
console.log('exiting...');
app.quit();
});

有没有办法找出可能导致这种情况的原因?


更新:我将 sandbox: true 添加到 webPreferences,现在它不再崩溃了!

最佳答案

Emitted when the renderer process crashes or is killed.

**Deprecated:** This event is superceded by the `render-process-gone` event
which contains more information about why the render process dissapeared. It
isn't always because it crashed. The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.

#### Event: 'render-process-gone'

Returns:

* `event` Event
* `details` Object
* `reason` String - The reason the render process is gone. Possible values:
* `clean-exit` - Process exited with an exit code of zero
* `abnormal-exit` - Process exited with a non-zero exit code
* `killed` - Process was sent a SIGTERM or otherwise killed externally
* `crashed` - Process crashed
* `oom` - Process ran out of memory
* `launch-failure` - Process never successfully launched
* `integrity-failure` - Windows code integrity checks failed

Emitted when the renderer process unexpectedly dissapears. This is normally
because it was crashed or killed.
  • 在应用程序上添加了新的 render-process-gone 事件以替换 renderer-process-crashed 事件。 #23560
  • 添加了新的 render-process-gone 事件来替换崩溃事件。 #23096

编号:https://github.com/electron/electron/pull/23096

https://github.com/electron/electron/pull/23560

关于javascript - Electron 存在而不会发出 render-process-gone 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63895390/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com