-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[Transition Tracing] Moved Transition Tracing Callback Code From Mutation to Passive Phase #24251
Conversation
Comparing: 5b2e725...47b4bfa Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
) { | ||
while (nextEffect !== null) { | ||
const fiber = nextEffect; | ||
|
||
if (enableTransitionTracing) { |
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.
This code should go in commitPassiveMountOnFiber
if (enableTransitionTracing) { | ||
const transitions = workInProgress.memoizedState.transitions; | ||
if (transitions !== null) { | ||
workInProgress.flags |= Visibility; |
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.
I don't think this is the right flag. I would use Passive instead.
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.
Also please leave a comment explaining why this flag is being set. It's not obvious from context.
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.
Does passive work here? We would want to know when to run the transition tracing specific code somehow right (ie. when a suspense boundary toggles). If passive is set it doesn't necessarily mean that the suspense boundary has toggled.
5f1f52f
to
09d1fbb
Compare
@@ -862,6 +862,14 @@ function completeWork( | |||
} | |||
case HostRoot: { | |||
const fiberRoot = (workInProgress.stateNode: FiberRoot); | |||
|
|||
if (enableTransitionTracing) { | |||
const transitions = workInProgress.memoizedState.transitions; |
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.
We only want to schedule an effect if there was actually a new transition. This will schedule an effect even if nothing changed.
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.
Oooh good catch
@@ -918,6 +926,11 @@ function completeWork( | |||
} | |||
updateHostContainer(current, workInProgress); | |||
bubbleProperties(workInProgress); | |||
if (enableTransitionTracing) { | |||
if ((workInProgress.subtreeFlags & Visibility) !== NoFlags) { | |||
workInProgress.flags |= Passive; |
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.
What's this for?
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.
If a suspense boundary toggles in visibility, we should also schedule a passive effect even if there are no new transitions because this might mean we completed the interaction (or the pending boundaries array changes at least)
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.
Ok makes sense, thanks for the added inline comment!
09d1fbb
to
1b56e7d
Compare
@@ -862,6 +863,17 @@ function completeWork( | |||
} | |||
case HostRoot: { | |||
const fiberRoot = (workInProgress.stateNode: FiberRoot); | |||
|
|||
if (enableTransitionTracing) { | |||
const transitions = getWorkInProgressTransitions(); |
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.
Reminder for me: This will change in next PR
1b56e7d
to
47b4bfa
Compare
This PR moves the code for transition tracing in the mutation phase that adds transitions to the pending callbacks object (to be called sometime later after paint) from the mutation to the passive phase. Things to think about: Passive effects can be flushed before or after paint. How do we make sure that we get the correct end time for the interaction?
Summary: This sync includes the following changes: - **[8dcedba15](facebook/react@8dcedba15 )**: Add fallback shim for AbortController ([#24285](facebook/react#24285)) //<Ricky>// - **[b86baa1cb](facebook/react@b86baa1cb )**: Add back lost cache test ([#24317](facebook/react#24317)) //<Ricky>// - **[bafe912a5](facebook/react@bafe912a5 )**: update types for InputContinuousLane and DefaultLane ([#24316](facebook/react#24316)) //<Leo>// - **[4ebaeae40](facebook/react@4ebaeae40 )**: moved mutation code to passive ([#24251](facebook/react#24251)) //<Luna Ruan>// - **[caa60e8fc](facebook/react@caa60e8fc )**: update types for NonIdleLanes and IdleLane ([#24313](facebook/react#24313)) //<Leo>// - **[1f7a901d7](facebook/react@1f7a901d7 )**: Fix false positive lint error with large number of branches ([#24287](facebook/react#24287)) //<Stephen Cyron>// - **[f56dfe950](facebook/react@f56dfe950 )**: Warn on setState() in useInsertionEffect() ([#24298](facebook/react#24298)) //<dan>// - **[d68b09def](facebook/react@d68b09def )**: Fix warning about setState in useEffect ([#24295](facebook/react#24295)) //<dan>// - **[057915477](facebook/react@057915477 )**: Update create-subscription README ([#24294](facebook/react#24294)) //<dan>// Changelog: [General][Changed] - React Native sync for revisions e8f4a66...8dcedba jest_e2e[run_all_tests] Reviewed By: kacieb Differential Revision: D35581147 fbshipit-source-id: 33661d77eb000fdedab7e506a458fc739eab0056
This PR moves the code for transition tracing in the mutation phase that adds transitions to the pending callbacks object (to be called sometime later after paint) from the mutation to the passive phase. Things to think about: Passive effects can be flushed before or after paint. How do we make sure that we get the correct end time for the interaction?
This PR moves the code for transition tracing in the mutation phase that adds transitions to the pending callbacks object (to be called sometime later after paint) from the mutation to the passive phase. Things to think about: Passive effects can be flushed before or after paint. How do we make sure that we get the correct end time for the interaction?
Summary: This sync includes the following changes: - **[8dcedba15](facebook/react@8dcedba15 )**: Add fallback shim for AbortController ([facebook#24285](facebook/react#24285)) //<Ricky>// - **[b86baa1cb](facebook/react@b86baa1cb )**: Add back lost cache test ([facebook#24317](facebook/react#24317)) //<Ricky>// - **[bafe912a5](facebook/react@bafe912a5 )**: update types for InputContinuousLane and DefaultLane ([facebook#24316](facebook/react#24316)) //<Leo>// - **[4ebaeae40](facebook/react@4ebaeae40 )**: moved mutation code to passive ([facebook#24251](facebook/react#24251)) //<Luna Ruan>// - **[caa60e8fc](facebook/react@caa60e8fc )**: update types for NonIdleLanes and IdleLane ([facebook#24313](facebook/react#24313)) //<Leo>// - **[1f7a901d7](facebook/react@1f7a901d7 )**: Fix false positive lint error with large number of branches ([facebook#24287](facebook/react#24287)) //<Stephen Cyron>// - **[f56dfe950](facebook/react@f56dfe950 )**: Warn on setState() in useInsertionEffect() ([facebook#24298](facebook/react#24298)) //<dan>// - **[d68b09def](facebook/react@d68b09def )**: Fix warning about setState in useEffect ([facebook#24295](facebook/react#24295)) //<dan>// - **[057915477](facebook/react@057915477 )**: Update create-subscription README ([facebook#24294](facebook/react#24294)) //<dan>// Changelog: [General][Changed] - React Native sync for revisions e8f4a66...8dcedba jest_e2e[run_all_tests] Reviewed By: kacieb Differential Revision: D35581147 fbshipit-source-id: 33661d77eb000fdedab7e506a458fc739eab0056
This PR moves the code for transition tracing in the mutation phase that adds transitions to the pending callbacks object (to be called sometime later after paint) from the mutation to the passive phase.
Things to think about: