Stop clobbering/leaking a provisional main frame on window close.
The browser can not delete a speculative main frame that has committed since the renderer takes ownership of it. This is a race since the renderer makes this decision, and the browser may try delete it before hearing it has been committed. In this case the renderer ignores the delete to avoid losing state. However as part of cancelling speculative navigation during shutdown, the browser will also replace the RenderFrameProxyHost which makes a RenderFrameProxy and RemoteFrame as the main frame in the renderer. This is a problem because it replaces Page's main_frame_ pointer to the main LocalFrame that was committed and not deleted by the browser's request. The LocalFrame becomes an orphan that lives indefinitely, with the LocalFrame and associated RenderFrame and WebViewFrameWidget holding raw pointers back to the WebViewImpl, the RenderWidget, and the RenderViewImpl. When these are closed and destroyed, if the process is not killed entirely, the frame will crash if it tries to access these. Since WebContentsImpl drops all RenderFrameProxyHosts before destroying the FrameTreeNode, we can not go through RenderFrameHostManager's CleanUpNavigation() or DiscardUnusedFrame() as this path will recreate the already deleted RenderFrameProxyHost, leading to the leaked frame. So instead we can simply delete the speculative RenderFrameHostImpl with UnsetSpeculativeRenderFrameHost(). This skips past recreating the RenderFrameProxyHost, setting the speculative RenderViewHost as being swapped out, and notifying in IPC that the nav was cancelled, none of which should matter to do at shutdown. R=avi@chromium.org, dcheng@chromium.org Bug: 964668, 838348, 915179 Change-Id: Icb7f2dfe6752ae745b0ea299fe4ca974b34516a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648463Reviewed-by:Daniel Cheng <dcheng@chromium.org> Reviewed-by:
Avi Drissman <avi@chromium.org> Reviewed-by:
Alex Moshchuk <alexmos@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/master@{#667139}
Showing
Please register or sign in to comment