Skip to content

[css-view-transitions-2] Separte MPA transition start from check #9819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 2, 2024

Conversation

noamr
Copy link
Collaborator

@noamr noamr commented Jan 18, 2024

In prepartion for the HTML integration and the pageconceal event, the check for whether cross-document view transition should take place is to be called twice from the HTML spec:

  • once when initiating the navigation, to check if a pageconceal event should be blocking
  • once right before firing pageconceal.

So separating the algorithm and exporting the check.

@noamr noamr requested a review from khushalsagar January 18, 2024 20:31
@khushalsagar
Copy link
Member

Still need to review the PR but one quick comment based on this statement.

once when initiating the navigation, to check if a pageconceal event should be blocking

The check should still be at 1 place after we have the final response. Because in the future it'll be based on the post redirect URL. We'll just run it in the browser (or parent process in Gecko?) to decide whether pageconceal needs to happen before VT capture steps.

@noamr
Copy link
Collaborator Author

noamr commented Jan 18, 2024

Still need to review the PR but one quick comment based on this statement.

once when initiating the navigation, to check if a pageconceal event should be blocking

The check should still be at 1 place after we have the final response. Because in the future it'll be based on the post redirect URL. We'll just run it in the browser (or parent process in Gecko?) to decide whether pageconceal needs to happen before VT capture steps.

I hope this would become clearer with the HTML PR :) but in the meantime:

We need to resolve the opt-in twice: once when the navigation is initiated and send that boolean to the browser process, and once right before pageconceal, given that it was blocking due to the opt-in being there when the navigation was initiated. We cannot read the opt-in directly in the browser process.

@khushalsagar
Copy link
Member

khushalsagar commented Jan 23, 2024

once when the navigation is initiated and send that boolean to the browser process, and once right before pageconceal, given that it was blocking due to the opt-in being there when the navigation was initiated. We cannot read the opt-in directly in the browser process.

Specs shouldn't have a concept of browser vs renderer process, this should be an implementation detail. This is the flow of events:

  1. Navigation is initiated.
  2. We have the final network response (in the browser process).

If we're evaluating the opt-in after 2) but before dispatching any events to the page, which implementation option we choose below wouldn't be web observable:

  • The browser sends an IPC to the renderer to evaluate the opt-in.
  • The renderer replicates the renderer's CSS state in the browser.

Do you see any issue with this?

@noamr
Copy link
Collaborator Author

noamr commented Jan 23, 2024

Specs shouldn't have a concept of browser vs renderer process, this should be an implementation detail.

Not accurate :) Much of the navigation flow occurs "in parallel", which means in a different thread/process, in this case that's what represents the browser process. So if during an "in parallel" flow we want to read something from the document (like run an algorithm that reads styles from current CSS), we have to queue a task on that document (which would be equivalent to an IPC call).

This is the flow of events:

  1. Navigation is initiated.
  2. We have the final network response (in the browser process).

If we're evaluating the opt-in after 2) but before dispatching any events to the page, which implementation option we choose below wouldn't be web observable:

  • The browser sends an IPC to the renderer to evaluate the opt-in.
  • The renderer replicates the renderer's CSS state in the browser.

Do you see any issue with this?

The issue is that this IPC means an unnecessary round-trip in case there is no opt-in, or in case the opt-in was already there when we started the navigation. The way I've specified it in the PR is that we read it when starting the navigation, without that extra round-trip after the final response.


1. If |oldDocument|'s [=environment settings object/origin=] is not [=same origin=] as
|newDocument|'s [=environment settings object/origin=] then call |onReady| and return.
1. If |oldOrigin| is not [=same origin=] as |newOrigin| then return false.

1. If |newDocument| [=was created via cross-origin redirects=] is true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an early return above for the "created with cross-origin redirects" case so we'll never hit this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, but I'll move this bit to the HTML spec PR. A navigation was created with a cross-origin redirects if:

  • the document was created with cross-origin redirects
  • this is not a BFCache restore

@noamr noamr merged commit e48ebbd into w3c:main Feb 2, 2024
@noamr noamr deleted the conceal branch February 2, 2024 12:00
domenic pushed a commit to whatwg/html that referenced this pull request Feb 29, 2024
See also w3c/csswg-drafts#9819.

The pageswap event is specified here to work as follows:

* It's sent whenever a document navigates away, to a different document, but not when unloaded for other reasons, such as closing the browser types or unloading an ancestor.

* It includes a NavigationActivation object for same-origin navigations.

* If the navigation might trigger a cross-document view-transition (this is determined when snapshotting the source document, by reading the CSS), pageswap is fired and then unloading is deferred until the old state is captured for the view transition. Otherwise, if the view transition is skipped, unloading happens immediately.

Closes #9702.
lozy219 pushed a commit to lozy219/html that referenced this pull request Mar 10, 2025
See also w3c/csswg-drafts#9819.

The pageswap event is specified here to work as follows:

* It's sent whenever a document navigates away, to a different document, but not when unloaded for other reasons, such as closing the browser types or unloading an ancestor.

* It includes a NavigationActivation object for same-origin navigations.

* If the navigation might trigger a cross-document view-transition (this is determined when snapshotting the source document, by reading the CSS), pageswap is fired and then unloading is deferred until the old state is captured for the view transition. Otherwise, if the view transition is skipped, unloading happens immediately.

Closes whatwg#9702.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants