Crashes when trying to stop WebContents during Navigation Starts |
||
Issue descriptionWhat steps will reproduce the problem? - Call WebContents.Stop() during WebContentsObserver.DidStartNavigation() What is the expected result? - Stop navigation What happens instead? - Crashed I am working on b/74124275 which I need to stop the current navigation and open up another WebContents. When I do so I see the crashes at NavigationRequest::BeginNavigation(). code location: https://cs.chromium.org/chromium/src/content/browser/frame_host/navigation_request.cc?rcl=eb780fd434496084168f4aade94cfb4e571d5225&l=549
,
Apr 13 2018
AFAIK this is not supported intentionally. Other WebContentsObservers will want to observe a navigation starting after your observer. If you want to stop the navigation in your observer, just post a task to WebContents::Stop, which should be safe.
,
Apr 13 2018
Comment 2 is correct. This is intentional to avoid a use-after-free on the pending NavigationEntry, which can't be discarded as we're in the middle of starting the navigation. Posting a task is the way to do this if you have to do it from a WebContentsObserver. NavigationThrottles may offer a better approach if you're trying to stop a navigation. |
||
►
Sign in to add a comment |
||
Comment 1 by yyzhong@chromium.org
, Apr 13 2018