diff --git a/atom/browser/web_view/web_view_manager.cc b/atom/browser/web_view/web_view_manager.cc index 032be04e7820..c638c18e123a 100644 --- a/atom/browser/web_view/web_view_manager.cc +++ b/atom/browser/web_view/web_view_manager.cc @@ -80,13 +80,19 @@ void WebViewManager::AddGuest(int guest_instance_id, } void WebViewManager::RemoveGuest(int guest_instance_id) { + if (!ContainsKey(web_contents_map_, guest_instance_id)) { + return; + } + auto web_contents = web_contents_map_[guest_instance_id].web_contents; + content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, base::Bind( &WebViewRendererState::RemoveGuest, base::Unretained(WebViewRendererState::GetInstance()), web_contents->GetRenderProcessHost()->GetID())); + web_contents_map_.erase(guest_instance_id); // Remove the record of element in embedder too.