-
Notifications
You must be signed in to change notification settings - Fork 49.7k
Solidify addTransitionType Semantics #32797
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
Conversation
|
Comparing: deca965...25af4b8 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
a028dc0 to
403a153
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point (not now) it would be nice to have tests to reference as specs for the behavior. For this one I think we could add Scheduler.log in the ViewTransition event to assert on the types if we shimmed startViewTransition?
Don't want to slow this down yet though, this is a good example of a change harder to make if you have to update a bunch of tests too.
Reviewed: sebmarkbage/react@f57175d...3399b16
403a153 to
21cd559
Compare
Conceptually they belong to each Transition object and should only be applied where updates to that batch are applied. However, since we batch regular Transitions together they go into the same set.
startTransition(() => {
startTransition(() => {
addTransitionType(...)
});
setState(...);
});
When the inner one finishes you could drop its transition types because it
has no work scheduled on it.
We store them on all roots that have been scheduled as part of the startTransition call. We shouldn't just let the first root that commits steal them all. Each root gets its own set.
…pes to every root that gets scheduled
21cd559 to
25af4b8
Compare
…Map (#32800) We have a high level concept for this used elsewhere. We should use this for `transitionTypes` too: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactInternalTypes.js#L285 As mentioned in #32797 we could also just use the `transitionLanes` since the `types` are also on the `Transition` objects. If we always stored this set.
…Map (#32800) We have a high level concept for this used elsewhere. We should use this for `transitionTypes` too: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactInternalTypes.js#L285 As mentioned in #32797 we could also just use the `transitionLanes` since the `types` are also on the `Transition` objects. If we always stored this set. DiffTrain build for [450f8df](450f8df)
Stacked on #32793.
This is meant to model the intended semantics of
addTransitionTypebetter. The previous hack just consumed all transition types when any root committed so it could steal them from other roots. Really each root should get its own set. Really each transition lane should get its own set.We can't implement the full ideal semantics yet because 1) we currently entangle transition lanes 2) we lack
AsyncContexton the client so for async actions we can't associate aaddTransitionTypecall to a specificstartTransition.This starts by modeling Transition Types to be stored on the Transition instance. Conceptually they belong to the Transition instance of that
startTransitionthey belong to. That instance is otherwise mostly just used for Transition Tracing but it makes sense that those would be able to be passed the Transition Types for that specific instance.Nested
startTransitionneed to get entangled. So that thisaddTransitionTypecan be associated with thesetState:Ideally we'd probably just use the same Transition instance itself since these are conceptually all part of one entangled one. But transition tracing uses multiple names and start times. Unclear what we want to do with that. So I kept separate instances but shared
typesset.Next I collect the types added during a
startTransitionto any root scheduled with a Transition. This should really be collected one set per Transition lane in aLaneMap. In fact, the information would already be there if Transition Tracing was always enabled because it tracks all Transition instances per lane. For now I just keep track of one set for all Transition lanes. Maybe we should only add it if asetStatewas done on this root in this particularstartTransitioncall rather having already scheduled any Transition earlier.While async transitions are entangled, we don't know if there will be a startTransition+setState on a new root in the future. Therefore, we collect all transition types while this is happening and if a new root gets startTransition+setState they get added to that root.