diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 3c0b9aeb9f326..a8a0514680e06 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -1042,8 +1042,18 @@ void RenderWidgetHostViewAura::ShowWithVisibility( } window_->Show(); +#if BUILDFLAG(IS_WIN) + // ShowImpl -> ... -> UpdateLegacyWin can spin a nested Win32 message loop and + // synchronously delete `this` (see the WARNING in + // NotifyHostAndDelegateOnWasShown). Guard the post-ShowImpl access below. + base::WeakPtr weak_this = + weak_ptr_factory_.GetWeakPtr(); +#endif // BUILDFLAG(IS_WIN) ShowImpl(page_visibility); #if BUILDFLAG(IS_WIN) + if (!weak_this) { + return; + } if (page_visibility != PageVisibilityState::kVisible && legacy_render_widget_host_HWND_) { legacy_render_widget_host_HWND_->Hide();