Skip to content

Commit 0589eef

Browse files
committed
Use the Task for "exit" in clones
If you're gesturing to something new and there are no updating or disappearing view transitions, then all view transitions are "exit" (because gestures are in reverse). These use the clone model which should track the animation task the same as applyViewTransitionToHostInstances. We also need to start the tracking earlier so it covers the insertion of clones.
1 parent 0a6ad8a commit 0589eef

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

packages/react-reconciler/src/ReactFiberApplyGesture.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ import {
7777
getViewTransitionClassName,
7878
} from './ReactFiberViewTransitionComponent';
7979

80+
import {
81+
enableProfilerTimer,
82+
enableComponentPerformanceTrack,
83+
} from 'shared/ReactFeatureFlags';
84+
import {trackAnimatingTask} from './ReactProfilerTimer';
85+
8086
let didWarnForRootClone = false;
8187

8288
// Used during the apply phase to track whether a parent ViewTransition component
@@ -101,6 +107,7 @@ function applyViewTransitionToClones(
101107
name: string,
102108
className: ?string,
103109
clones: Array<Instance>,
110+
fiber: Fiber,
104111
): void {
105112
// This gets called when we have found a pair, but after the clone in created. The clone is
106113
// created by the insertion side. If the insertion side if found before the deletion side
@@ -117,6 +124,11 @@ function applyViewTransitionToClones(
117124
className,
118125
);
119126
}
127+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
128+
if (fiber._debugTask != null) {
129+
trackAnimatingTask(fiber._debugTask);
130+
}
131+
}
120132
}
121133

122134
function trackDeletedPairViewTransitions(deletion: Fiber): void {
@@ -171,7 +183,7 @@ function trackDeletedPairViewTransitions(deletion: Fiber): void {
171183
// If we have clones that means that we've already visited this
172184
// ViewTransition boundary before and we can now apply the name
173185
// to those clones. Otherwise, we have to wait until we clone it.
174-
applyViewTransitionToClones(name, className, clones);
186+
applyViewTransitionToClones(name, className, clones, child);
175187
}
176188
}
177189
if (pairs.size === 0) {
@@ -221,7 +233,7 @@ function trackEnterViewTransitions(deletion: Fiber): void {
221233
// If we have clones that means that we've already visited this
222234
// ViewTransition boundary before and we can now apply the name
223235
// to those clones. Otherwise, we have to wait until we clone it.
224-
applyViewTransitionToClones(name, className, clones);
236+
applyViewTransitionToClones(name, className, clones, deletion);
225237
}
226238
}
227239
}
@@ -266,7 +278,7 @@ function applyAppearingPairViewTransition(child: Fiber): void {
266278
// If there are no clones at this point, that should mean that there are no
267279
// HostComponent children in this ViewTransition.
268280
if (clones !== null) {
269-
applyViewTransitionToClones(name, className, clones);
281+
applyViewTransitionToClones(name, className, clones, child);
270282
}
271283
}
272284
}
@@ -296,7 +308,7 @@ function applyExitViewTransition(placement: Fiber): void {
296308
// If there are no clones at this point, that should mean that there are no
297309
// HostComponent children in this ViewTransition.
298310
if (clones !== null) {
299-
applyViewTransitionToClones(name, className, clones);
311+
applyViewTransitionToClones(name, className, clones, placement);
300312
}
301313
}
302314
}
@@ -314,7 +326,7 @@ function applyNestedViewTransition(child: Fiber): void {
314326
// If there are no clones at this point, that should mean that there are no
315327
// HostComponent children in this ViewTransition.
316328
if (clones !== null) {
317-
applyViewTransitionToClones(name, className, clones);
329+
applyViewTransitionToClones(name, className, clones, child);
318330
}
319331
}
320332
}
@@ -346,7 +358,7 @@ function applyUpdateViewTransition(current: Fiber, finishedWork: Fiber): void {
346358
// If there are no clones at this point, that should mean that there are no
347359
// HostComponent children in this ViewTransition.
348360
if (clones !== null) {
349-
applyViewTransitionToClones(oldName, className, clones);
361+
applyViewTransitionToClones(oldName, className, clones, finishedWork);
350362
}
351363
}
352364

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4260,6 +4260,10 @@ function commitGestureOnRoot(
42604260
}
42614261
deleteScheduledGesture(root, finishedGesture);
42624262

4263+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
4264+
startAnimating(pendingEffectsLanes);
4265+
}
4266+
42634267
const prevTransition = ReactSharedInternals.T;
42644268
ReactSharedInternals.T = null;
42654269
const previousPriority = getCurrentUpdatePriority();
@@ -4277,9 +4281,6 @@ function commitGestureOnRoot(
42774281
pendingTransitionTypes = finishedGesture.types;
42784282
pendingEffectsStatus = PENDING_GESTURE_MUTATION_PHASE;
42794283

4280-
if (enableProfilerTimer && enableComponentPerformanceTrack) {
4281-
startAnimating(pendingEffectsLanes);
4282-
}
42834284
pendingViewTransition = finishedGesture.running = startGestureTransition(
42844285
suspendedState,
42854286
root.containerInfo,

0 commit comments

Comments
 (0)