From bff20bd7691d65ad0b35d2726e19a65d80de16dc Mon Sep 17 00:00:00 2001 From: Keeley Hammond Date: Thu, 14 Oct 2021 09:44:44 -0700 Subject: [PATCH] fix: reset render_frame_disposed_ after render frame host change (#31401) * fix: reset render_frame_disposed_ after hang * fix: handle exception in webContents.send --- lib/browser/api/web-frame-main.ts | 12 ++++++++++-- shell/browser/api/electron_api_web_frame_main.cc | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/browser/api/web-frame-main.ts b/lib/browser/api/web-frame-main.ts index 1ef76aa6f847..2f75ee615a69 100644 --- a/lib/browser/api/web-frame-main.ts +++ b/lib/browser/api/web-frame-main.ts @@ -7,7 +7,11 @@ WebFrameMain.prototype.send = function (channel, ...args) { throw new Error('Missing required channel argument'); } - return this._send(false /* internal */, channel, args); + try { + return this._send(false /* internal */, channel, args); + } catch (e) { + console.error('Error sending from webFrameMain: ', e); + } }; WebFrameMain.prototype._sendInternal = function (channel, ...args) { @@ -15,7 +19,11 @@ WebFrameMain.prototype._sendInternal = function (channel, ...args) { throw new Error('Missing required channel argument'); } - return this._send(true /* internal */, channel, args); + try { + return this._send(true /* internal */, channel, args); + } catch (e) { + console.error('Error sending from webFrameMain: ', e); + } }; WebFrameMain.prototype.postMessage = function (...args) { diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 8f934108a173..c5a5945ba0a2 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -100,7 +100,7 @@ void WebFrameMain::MarkRenderFrameDisposed() { void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) { // Should only be called when swapping frames. - DCHECK(render_frame_); + render_frame_disposed_ = false; render_frame_ = rfh; renderer_api_.reset(); }