-
Notifications
You must be signed in to change notification settings - Fork 711
[css-view-transitions-1] Clarify timing of updateCallbackDone
#9762
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
It's worth checking with @domenic or @annevk on this. Adding microtask checkpoints to solve race conditions is usually a bad smell. In userland, promises don't shuffle the order of reaction callbacks, or provide a way to do this. Could you document some of the bugs you're seeing as a result of the current behaviour? There could be another solution. |
Agreed, would love to find a more elegant way around this if this is indeed a spec bug.
The context is https://bugs.chromium.org/p/chromium/issues/detail?id=1513887 |
From the bug:
Should those things be considered equivalent? Doing something after it's done shouldn't be equivalent to doing something before it's done. One of the reasons we have an |
That's fair, but then it should be consistent and not racy. If the author wants a promise that always resolves after everything is captured, |
If this is worth fixing, it seems like the right way is to make sure the reaction callbacks in https://drafts.csswg.org/css-view-transitions-1/#setup-view-transition-algorithm (5.3) are added as soon as the update callback done promise is created. That way the spec's reaction callback will always be first. |
You mean fixing it so that It's perhaps worth a discussion, I think the purpose of |
No, because
Does the example here make sense? https://developer.chrome.com/docs/web-platform/view-transitions/#transitions_as_an_enhancement Also see the docs here https://drafts.csswg.org/css-view-transitions-1/#ref-for-dom-viewtransition-updatecallbackdone%E2%91%A0
It doesn't do that, and that isn't what it's designed for. If you need to extend the update callback, you should be adding more to the update callback. That's why it's a callback rather than a promise, else we lose the ability to catch errors etc. |
In case the above doesn't explain it well, here's another description:
For example, when intercepting a navigation using the navigation API, the handler returns a promise relating to the success/failure of the navigation. A failed transition isn't a failed navigation, so if you're wrapping your DOM change in |
OK, proposing to resolve on making the order of events consistent:
|
^ The goal of the above is to ensure capturing new state deterministically happens before updateCallbackDone is resolved. If so, that SGTM. |
updateCallbackDone
updateCallbackDone
Apparently this is already what's implemented in Chromium, so I'll update the spec to make it clearer. |
Currently
updateCallbackDone
is a reaction to the providedupdate
callback (instartViewTransition(update)
),and activating the view transition is a reaction to
updateCallbackDone
.This makes it so that author-provided
updateCallbackDone
reactions are usually called before capturing the new state, but sometimes after. This can create a confusion and subtle bugs.I found that
updateCallbackDone
is most useful in its usual behavior, when all the author reactions are flushed and only then the new state is captured - this allows using this callback as a way to add new state changes on top of whatever is in the update callbackProposing to slightly change the wording so that it's clear that there's a microtask checkpoint between resolving
updateCallbackDone
and activating the view transition (capturing the new state).The text was updated successfully, but these errors were encountered: