From 7bf6f5ec26fc86f993319c4317a2ede7e6f50de1 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 3 Sep 2020 18:41:32 -0700 Subject: [PATCH 1/2] chore: log hint on renderer crash --- lib/browser/api/web-contents.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 3e4efe716a825..448cc66d5c776 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -525,6 +525,11 @@ WebContents.prototype._init = function () { this.on('crashed', (event, ...args) => { app.emit('renderer-process-crashed', event, this, ...args); + + // Log out a hint to help users better debug renderer crashes. + if (!process.env.ELECTRON_ENABLE_LOGGING) { + console.info('Renderer process crashed - setting ELECTRON_ENABLE_LOGGING may provide more information.'); + } }); this.on('render-process-gone', (event, ...args) => { From 2ee1e2e80f08497c7bcfb4c9c18a5a41d15385d4 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 14 Sep 2020 08:58:07 -0600 Subject: [PATCH 2/2] Address feedback from review --- lib/browser/api/web-contents.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 448cc66d5c776..c5abb4388eb37 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -459,6 +459,11 @@ const addReturnValueToEvent = (event) => { }); }; +const loggingEnabled = () => { + return Object.prototype.hasOwnProperty.call(process.env, 'ELECTRON_ENABLE_LOGGING') || + process.argv.some(arg => arg.toLowerCase().startsWith('--enable-logging')); +}; + // Add JavaScript wrappers for WebContents class. WebContents.prototype._init = function () { // The navigation controller. @@ -527,8 +532,8 @@ WebContents.prototype._init = function () { app.emit('renderer-process-crashed', event, this, ...args); // Log out a hint to help users better debug renderer crashes. - if (!process.env.ELECTRON_ENABLE_LOGGING) { - console.info('Renderer process crashed - setting ELECTRON_ENABLE_LOGGING may provide more information.'); + if (loggingEnabled()) { + console.info('Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.'); } });