Noam Rosenthal
@nomster.bsky.social
970 followers 680 following 210 posts
Web platform engineer @ Chrome
Posts Media Videos Starter Packs
nomster.bsky.social
But it has a PWA as well... I have both installed for comparison.
nomster.bsky.social
Awesome, seems like you're all sorted!
nomster.bsky.social
It's a question of whether tick should mean "ASAP, but definitely after all the microtasks, but definitely before the next paint" vs. "as late as possible, but before next paint, but ASAP if painting is suppressed for some reason"

I am not well versed in Svelte enough to say what's "better" :)
nomster.bsky.social
Of course, but the comment says "in almost all cases requestAnimationFrame will fire first" which is incorrect.

This would mean that you would now often have multiple ticks in the same frame in the normal (no view transition) case.
nomster.bsky.social
rAF wouldn't always beat setTimeout(f, 0). you can get multiple timeout calls in the same frame.
nomster.bsky.social
If you were using rAF up until now then the difference won't be concrete/noticeable I guess.
nomster.bsky.social
... also, we take feedback from web developers and framework authors very seriously, so please keep at it!
nomster.bsky.social
Ah yes, makes sense.

I would suggest calling scheduler.yield() there in case you are waiting on a VT callback, falling back to setTimeout if that's not supported in the browser.
nomster.bsky.social
Well we detect that the transition timed out, not necessarily due to a deadlock... I think the animation panel gives some indication when that happens? I'll check with the team.
nomster.bsky.social
Interesting... not trivial though!
Knowing that this is a deadlock requires static analysis that predicts that the promise resolution has some kind of dependency on the rAF. There could be legit use cases for calling rAF in the callback as long as the promise resolution doesn't depend on it.
nomster.bsky.social
Racing - Is this in order to have some sort of time limit for the callback? Can you expand on the use case and perhaps this has some other avenue?

I totally emphasize with the annoyance, a few things in view transitions are not trivial, some for a good reason. This one specifically is unavoidable.
nomster.bsky.social
... But ordinary non-rendering tasks continue as normal, so setTimeout callbacks are still called.
nomster.bsky.social
It's by design and in the spec.
When we await the callback promise, rendering is paused until the new state of the DOM is settled, and so are rAFs. Having no frames (and thus no rAF) between view transition "start" and "active" ensures that the animation starts at the old state.
nomster.bsky.social
Yea there was a common theme of feedback during the last year or so about the "frozen middle bit" of a cross-document view transition
nomster.bsky.social
(For now just trying it out in chromium to see if the resulting UX is nice)
nomster.bsky.social
Yes, you got it right!
nomster.bsky.social
... But it's worth trying out all this stuff to make sure the various cases are covered.
nomster.bsky.social
If you use shadow DOM for encapsulation and the view transition is inside the shadow you might not need tag containment, as the shadow boundary already does that.
nomster.bsky.social
Thanks, good point! I will report it so that it's corrected.
nomster.bsky.social
What happened is that we've made view-transition names shadow-scoped at some point, so after that you couldn't make document-scoped view-transition that pierce shadow roots, and have to use ::part for that.

But if the whole view-transition is scoped inside the shadow you should be fine methinks.
nomster.bsky.social
By design they should "just work" with the view-transition-name matching working only within the scope.

I haven't tested this myself though.