From 98c039c880068ff2d31ebec99aeaf3b2af6fdc20 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 20 Mar 2017 12:22:46 -0700 Subject: [PATCH] Detach from devtools before destroying Otherwise Electron would crash on exit in Chrome 58. --- brightray/browser/inspectable_web_contents_impl.cc | 13 ++++++++++--- brightray/vendor/libchromiumcontent | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index f4eb15d3650b..8efb160f63f3 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -235,9 +235,14 @@ InspectableWebContentsImpl::InspectableWebContentsImpl( } InspectableWebContentsImpl::~InspectableWebContentsImpl() { - if (devtools_web_contents_) - devtools_web_contents_->Close(); - Observe(nullptr); + // Unsubscribe from devtools and Clean up resources. + if (devtools_web_contents_) { + devtools_web_contents_->SetDelegate(nullptr); + // Calling this also unsubscribes the observer, so WebContentsDestroyed + // won't be called again. + WebContentsDestroyed(); + } + // Let destructor destroy devtools_web_contents_. } InspectableWebContentsView* InspectableWebContentsImpl::GetView() const { @@ -651,6 +656,7 @@ void InspectableWebContentsImpl::RenderFrameHostChanged( void InspectableWebContentsImpl::WebContentsDestroyed() { frontend_loaded_ = false; + Observe(nullptr); Detach(); for (const auto& pair : pending_requests_) @@ -695,6 +701,7 @@ void InspectableWebContentsImpl::HandleKeyboardEvent( } void InspectableWebContentsImpl::CloseContents(content::WebContents* source) { + // This is where the devtools closes itself (by clicking the x button). CloseDevTools(); } diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 8c3e53238581..791141a820ec 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 8c3e532385811b5cea80e969c1beb1bf3ffb6777 +Subproject commit 791141a820ecf6166a86249701838b57f43777ea