-
Notifications
You must be signed in to change notification settings - Fork 711
[css-view-transitions] Behavior of calling document.startViewTransition
synchronously more than once
#11292
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
Comments
The best practice here would be to use const $input = $label.querySelector('input');
await document.startViewTransition(() => {
$input.checked = !$input.checked;
}).updateCallbackDone;
document.startViewTransition(() => {
document.body.style.padding = `${Math.random() * 10}rem`;
}); |
Sure, that would fix that demo so that it’s consistent across browsers. But I also would love to see it work interoperably without that fix. I’m fine with whatever the outcome is (altough I expected Safari’s behavior to occur; but also see that Chrome’s behavior seems interesting). My main concern is interop here. |
An important detail here is that update callbacks can also be asynchronous and have multiple steps; we can queue them in such a way that they would start in the order of their respective view transitions, but without awaiting it would be constrained to a subset of those callbacks. |
@emilio @jakearchibald @nt1m any takes on this? |
The Safari implementation is definitely wrong, as it violates the intent that transitions are an enhancement.
It'd be nice to remove the race condition somehow though. |
Ah right, I was reading it as Safari was executing them in order. Not calling the update callback at all is definitely wrong and a spec violation. Surprised that we don't have WPTs for this.
Happy to resolve on something and spec it. It's not complex to fix. |
Proposing the following resolution: the update callbacks would be maintained in an internal queue rather than separately on the event loop, and when "calling the update callback" all of them would be invoked. |
But Safari is executing the first callback (the one that changes One could say Chrome is in the wrong here, because it changes the |
Ah, my bad, I interpreted the above incorrectly.
Yeah, I agree that's nice. |
The Safari behavior? |
Yes. Sorry, that wasn't clear. The Safari behaviour where it makes the previous transition do all its cancelation behaviours before the new transition does any of its capturing sounds good. |
Let's tag this for async resolution? @astearns |
PROPOSED RESOLUTION: When starting a new view transition, have the previous active transition do all its cancelation behaviours before the new transition does any of its capturing. |
I‘d like to see some WebKit confirmation on this proposed resolution. |
The resolution is to adopt the current webkit behavior |
Sounds good |
The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment. Proposed Resolution: When starting a new view transition, have the previous active transition do all its cancelation behaviours before the new transition does any of its capturing. |
RESOLVED: When starting a new view transition, have the previous active transition do all its cancelation behaviours before the new transition does any of its capturing. |
…re capturing the new state. Closes w3c#11292
Demo: https://codepen.io/bramus/pen/gOVyzjL
This demo has two successive calls to
document.startViewTransition
:When you check this in Chrome, the code from both callbacks get executed as part of the View Transition: the faux
<details>
opens/closes using an animation + it also moves around because the padding of the<body>
was changed.When you check this in Safari, only the code from the second callback gets executed as part of the View Transition: the faux
<details>
is immediately opened/closed and only moves around because the padding of the<body>
was changed.As per spec, the second call to
document.startViewTransition
should skip any active view transition, which led me to believe Safari is doing the right thing here.Checking things with @noamr, he says it’s racy in the spec:
I’m not sure if an how we can solve, but I surely would love to see all implementations behave the same by having intstructions for what to do in this case baked into the spec.
The text was updated successfully, but these errors were encountered: