Skip to content

Commit 982863c

Browse files
committed
Log "Starting Animation" and "Animating" for Gesture Track
1 parent fdcef1c commit 982863c

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,9 @@ export function startViewTransition(
23202320
mutationCallback();
23212321
layoutCallback();
23222322
// Skip afterMutationCallback(). We don't need it since we're not animating.
2323+
if (enableProfilerTimer) {
2324+
finishedAnimation();
2325+
}
23232326
spawnedWorkCallback();
23242327
// Skip passiveCallback(). Spawned work will schedule a task.
23252328
return null;
@@ -2509,6 +2512,7 @@ export function startGestureTransition(
25092512
mutationCallback: () => void,
25102513
animateCallback: () => void,
25112514
errorCallback: mixed => void,
2515+
finishedAnimation: () => void, // Profiling-only
25122516
): null | RunningViewTransition {
25132517
const ownerDocument: Document =
25142518
rootContainer.nodeType === DOCUMENT_NODE
@@ -2723,6 +2727,12 @@ export function startGestureTransition(
27232727
// $FlowFixMe[prop-missing]
27242728
ownerDocument.__reactViewTransition = null;
27252729
}
2730+
if (enableProfilerTimer) {
2731+
// Signal that the Transition was unable to continue. We do that here
2732+
// instead of when we stop the running View Transition to ensure that
2733+
// we cover cases when something else stops it early.
2734+
finishedAnimation();
2735+
}
27262736
});
27272737
return transition;
27282738
} catch (x) {
@@ -2735,6 +2745,9 @@ export function startGestureTransition(
27352745
// Run through the sequence to put state back into a consistent state.
27362746
mutationCallback();
27372747
animateCallback();
2748+
if (enableProfilerTimer) {
2749+
finishedAnimation();
2750+
}
27382751
return null;
27392752
}
27402753
}

packages/react-native-renderer/src/ReactFiberConfigNative.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
} from 'react-reconciler/src/ReactEventPriorities';
3636
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
3737

38+
import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
39+
3840
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
3941
import type {ReactContext} from 'shared/ReactTypes';
4042

@@ -680,6 +682,9 @@ export function startViewTransition(
680682
layoutCallback();
681683
// Skip afterMutationCallback(). We don't need it since we're not animating.
682684
spawnedWorkCallback();
685+
if (enableProfilerTimer) {
686+
finishedAnimation();
687+
}
683688
// Skip passiveCallback(). Spawned work will schedule a task.
684689
return null;
685690
}
@@ -696,9 +701,13 @@ export function startGestureTransition(
696701
mutationCallback: () => void,
697702
animateCallback: () => void,
698703
errorCallback: mixed => void,
704+
finishedAnimation: () => void, // Profiling-only
699705
): null | RunningViewTransition {
700706
mutationCallback();
701707
animateCallback();
708+
if (enableProfilerTimer) {
709+
finishedAnimation();
710+
}
702711
return null;
703712
}
704713

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,6 +4268,9 @@ function commitGestureOnRoot(
42684268
pendingTransitionTypes = finishedGesture.types;
42694269
pendingEffectsStatus = PENDING_GESTURE_MUTATION_PHASE;
42704270

4271+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
4272+
startAnimating(pendingEffectsLanes);
4273+
}
42714274
pendingViewTransition = finishedGesture.running = startGestureTransition(
42724275
suspendedState,
42734276
root.containerInfo,
@@ -4278,6 +4281,10 @@ function commitGestureOnRoot(
42784281
flushGestureMutations,
42794282
flushGestureAnimations,
42804283
reportViewTransitionError,
4284+
enableProfilerTimer
4285+
? // This callback fires after "pendingEffects" so we need to snapshot the arguments.
4286+
finishedViewTransition.bind(null, pendingEffectsLanes)
4287+
: (null: any),
42814288
);
42824289
}
42834290

@@ -4320,6 +4327,23 @@ function flushGestureAnimations(): void {
43204327
if (pendingEffectsStatus !== PENDING_GESTURE_ANIMATION_PHASE) {
43214328
return;
43224329
}
4330+
4331+
const lanes = pendingEffectsLanes;
4332+
4333+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
4334+
// Update the new commitEndTime to when we started the animation.
4335+
recordCommitEndTime();
4336+
logStartViewTransitionYieldPhase(
4337+
pendingEffectsRenderEndTime,
4338+
commitEndTime,
4339+
pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT,
4340+
animatingTask,
4341+
);
4342+
if (pendingDelayedCommitReason !== ABORTED_VIEW_TRANSITION_COMMIT) {
4343+
pendingDelayedCommitReason = ANIMATION_STARTED_COMMIT;
4344+
}
4345+
}
4346+
43234347
pendingEffectsStatus = NO_PENDING_EFFECTS;
43244348
const root = pendingEffectsRoot;
43254349
const finishedWork = pendingFinishedWork;
@@ -4344,6 +4368,10 @@ function flushGestureAnimations(): void {
43444368
ReactSharedInternals.T = prevTransition;
43454369
}
43464370

4371+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
4372+
finalizeRender(lanes, commitEndTime);
4373+
}
4374+
43474375
// Now that we've rendered this lane. Start working on the next lane.
43484376
ensureRootIsScheduled(root);
43494377
}

packages/react-test-renderer/src/ReactFiberConfigTestHost.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
NoEventPriority,
1818
type EventPriority,
1919
} from 'react-reconciler/src/ReactEventPriorities';
20+
import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
2021

2122
export {default as rendererVersion} from 'shared/ReactVersion'; // TODO: Consider exporting the react-native version.
2223
export const rendererPackageName = 'react-test-renderer';
@@ -446,9 +447,13 @@ export function startGestureTransition(
446447
mutationCallback: () => void,
447448
animateCallback: () => void,
448449
errorCallback: mixed => void,
450+
finishedAnimation: () => void, // Profiling-only
449451
): null | RunningViewTransition {
450452
mutationCallback();
451453
animateCallback();
454+
if (enableProfilerTimer) {
455+
finishedAnimation();
456+
}
452457
return null;
453458
}
454459

0 commit comments

Comments
 (0)