Commit c9ab1fb0 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Don't call RemoteMainFrameHost::RouteCloseEvent() on unbound remote

It seems possible that a race condition to happen between WebViewImpl's
CloseWindowSoon() schedules a call to DoDeferredCloseWindowSoon() and
that method actually being called: even though WebViewImpl will be
alive (otherwise the weak pointer would have prevented that callback
from being called), WebViewImpl::DidDetachRemoteMainFrame() might have
been called in between those two points, unbinding the remote and
causing the issue reported as part of crbug.com/1127329.

Bug: 1127329
Change-Id: I189fc1b38f315dc420d97eda5b5c01d346db8033
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409499Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#806730}
parent ebba8ce7
......@@ -303,11 +303,13 @@ void WebViewImpl::CloseWindowSoon() {
}
void WebViewImpl::DoDeferredCloseWindowSoon() {
// The main widget is currently not active. The active main frame widget is
// in a different process. Have the browser route the close request to the
// active widget instead, so that the correct unload handlers are run.
DCHECK(remote_main_frame_host_remote_);
remote_main_frame_host_remote_->RouteCloseEvent();
// The main widget is currently not active. The active main frame widget is in
// a different process. Have the browser route the close request to the active
// widget instead, so that the correct unload handlers are run. We do an early
// return instead of a DCHECK to guard against DidDetachRemoteMainFrame()
// being called between this method is schedule and when it's actually run.
if (remote_main_frame_host_remote_.is_bound())
remote_main_frame_host_remote_->RouteCloseEvent();
}
WebViewImpl::WebViewImpl(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment