When I press a button on a certain website loaded in a BrowserView
, the electron app exits. It's obviously a crash, but it doesn't emit the render-process-gone
neither on the BrowserWindow (renderer) or the BrowserView. It just quits. But window-all-closed
is emited
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();
});
Is there a way to find out what could be causing this?
update: I added sandbox: true
to the webPreferences and now it doesn't crash anymore!
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
event on app to replace the renderer-process-crashed
event. #23560render-process-gone
event to replace the crashed event. #23096