Skip to content

Commit

Permalink
Wait for renderer-initiated navigation cancellations using RendererCa…
Browse files Browse the repository at this point in the history
…ncellationThrottle

Renderer-initiated navigations can be cancelled from the JS task it was
initiated from, e.g. if the script runs window.stop() after initiating
the navigation. See also whatwg/html#3447 and
https://crbug.com/763106 for more background.

The renderer cancels navigation by triggering the disconnection of the
NavigationClient interface used to start the navigation, eventually
calling `NavigationRequest::OnRendererAbortedNavigation()`.
Same-SiteInstanceGroup navigations used to use the same NavigationClient
for starting and committing navigation. This means even if a
CommitNavigation IPC is in-flight at the time of navigation
cancellation, the navigation can still get cancelled. Since the same
RenderFrame is reused, the CommitNavigation IPC also implicitly waits
for the JS task that triggers the navigation to finish, as the commit
can't be processed before then. However, with RenderDocument, the
RenderFrame and NavigationClient won't be reused, which means
navigation cancellations might only affect navigations that haven't
entered READY_TO_COMMIT stage.

This CL introduces RendererCancellationThrottle, which helps preserve
the previous behavior by waiting for the JS task to finish, through
deferring the navigations before it gets into the READY_TO_COMMIT
stage until the renderer that started the navigation calls the
`RendererCancellationWindowEnded` method on the per-navigation
NavigationRendererCancellationListener interface (also added by
this CL), signifying that the JS task that initiated the
navigation had ended and no more renderer-initiated navigation
cancellations can happen.

See also: https://docs.google.com/document/d/1VNmvEVuaiNH3ypt6YfrYPsJJp8okCTYjooekarOiWN8/edit#heading=h.71sdg5clbek8

Bug: 936696
Change-Id: I07393142c3fa03c1b3937147f730cc4e6dca4eff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3561214
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: John Delaney <johnidel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1025993}
NOKEYCHECK=True
GitOrigin-RevId: af55b5b6ebe03da36d40e71bd733617291c6c9c7
  • Loading branch information
rakina authored and Copybara-Service committed Jul 20, 2022
1 parent d3414cf commit 0bf8881
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tracing/protos/chrome_track_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ message RendererMainThreadTaskExecution {
TASK_TYPE_INTERNAL_INPUT_BLOCKING = 77;
TASK_TYPE_WEB_GPU = 78;
TASK_TYPE_INTERNAL_POST_MESSAGE_FORWARDING = 79;
TASK_TYPE_INTERNAL_NAVIGATION_CANCELLATION = 80;
}

enum FrameType {
Expand Down

0 comments on commit 0bf8881

Please sign in to comment.