From a05ed73f43f6302f19f4b084842a8e4808fe99b9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:52:46 -0700 Subject: [PATCH] fix: reset render_frame_disposed_ after render frame host change (#31426) * fix: reset render_frame_disposed_ after hang * fix: handle exception in webContents.send Co-authored-by: VerteDinde Co-authored-by: VerteDinde --- 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 1ef76aa6f847a..2f75ee615a697 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 a6415ef83903c..c077d7394fdd3 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(); }