fix: prevent crash if BrowserView webContents was destroyed (#25112)

This commit is contained in:
Shelley Vohr 2020-08-25 20:04:13 -07:00 committed by GitHub
parent c97f8109c2
commit c8a0b2b71d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 32 deletions

View file

@ -658,7 +658,8 @@ WebContents::~WebContents() {
} else {
// Destroy WebContents asynchronously unless app is shutting down,
// because destroy() might be called inside WebContents's event handler.
DestroyWebContents(!IsGuest() /* async */);
bool is_browser_view = type_ == Type::BROWSER_VIEW;
DestroyWebContents(!(IsGuest() || is_browser_view) /* async */);
// The WebContentsDestroyed will not be called automatically because we
// destroy the webContents in the next tick. So we have to manually
// call it here to make sure "destroyed" event is emitted.