cefclient: win: Fix crash on close with --use-native (see #3239)

OnBeforeClose notification is delivered via TabModel destruction in
TabStripModel::SendDetachWebContentsNotifications. We need to let
that call stack unwind before triggering TabStripModel destruction
via closure of the native host window.
This commit is contained in:
Marshall Greenblatt 2024-05-20 18:14:00 -04:00
parent 48137b9538
commit c7b30ee80f

View File

@ -1074,9 +1074,10 @@ void RootWindowWin::OnBrowserWindowDestroyed() {
if (!window_destroyed_) {
// The browser was destroyed first. This could be due to the use of
// off-screen rendering or execution of JavaScript window.close().
// Close the RootWindow.
Close(true);
// off-screen rendering or native (external) parent, or execution of
// JavaScript window.close(). Close the RootWindow asyncronously to allow
// the current call stack to unwind.
MAIN_POST_CLOSURE(base::BindOnce(&RootWindowWin::Close, this, true));
}
browser_destroyed_ = true;