-
Notifications
You must be signed in to change notification settings - Fork 49.9k
[Transition Tracing] Moved Transition Tracing Callback Code From Mutation to Passive Phase #24251
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,7 @@ import { | |
| popRenderLanes, | ||
| getRenderTargetTime, | ||
| subtreeRenderLanes, | ||
| getWorkInProgressTransitions, | ||
| } from './ReactFiberWorkLoop.new'; | ||
| import { | ||
| OffscreenLane, | ||
|
|
@@ -862,6 +863,17 @@ function completeWork( | |
| } | ||
| case HostRoot: { | ||
| const fiberRoot = (workInProgress.stateNode: FiberRoot); | ||
|
|
||
| if (enableTransitionTracing) { | ||
| const transitions = getWorkInProgressTransitions(); | ||
| // We set the Passive flag here because if there are new transitions, | ||
| // we will need to schedule callbacks and process the transitions, | ||
| // which we do in the passive phase | ||
| if (transitions !== null) { | ||
| workInProgress.flags |= Passive; | ||
| } | ||
| } | ||
|
|
||
| if (enableCache) { | ||
| popRootTransition(fiberRoot, renderLanes); | ||
|
|
||
|
|
@@ -918,6 +930,14 @@ function completeWork( | |
| } | ||
| updateHostContainer(current, workInProgress); | ||
| bubbleProperties(workInProgress); | ||
| if (enableTransitionTracing) { | ||
| if ((workInProgress.subtreeFlags & Visibility) !== NoFlags) { | ||
| // If any of our suspense children toggle visibility, this means that | ||
| // the pending boundaries array needs to be updated, which we only | ||
| // do in the passive phase. | ||
| workInProgress.flags |= Passive; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this for?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok makes sense, thanks for the added inline comment! |
||
| } | ||
| } | ||
| return null; | ||
| } | ||
| case HostComponent: { | ||
|
|
@@ -1187,6 +1207,12 @@ function completeWork( | |
| const offscreenFiber: Fiber = (workInProgress.child: any); | ||
| offscreenFiber.flags |= Visibility; | ||
|
|
||
| // If the suspended state of the boundary changes, we need to schedule | ||
| // a passive effect, which is when we process the transitions | ||
| if (enableTransitionTracing) { | ||
| offscreenFiber.flags |= Passive; | ||
| } | ||
|
|
||
| // TODO: This will still suspend a synchronous tree if anything | ||
| // in the concurrent tree already suspended during this render. | ||
| // This is a known bug. | ||
|
|
||
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