@@ -83,6 +83,8 @@ import {
8383 logSuspendedCommitPhase ,
8484 logCommitPhase ,
8585 logPaintYieldPhase ,
86+ logStartViewTransitionYieldPhase ,
87+ logAnimatingPhase ,
8688 logPassiveCommitPhase ,
8789 logYieldTime ,
8890 logActionYieldTime ,
@@ -674,6 +676,11 @@ const IMMEDIATE_COMMIT = 0;
674676const SUSPENDED_COMMIT = 1 ;
675677const THROTTLED_COMMIT = 2 ;
676678
679+ type DelayedCommitReason = 0 | 1 | 2 | 3 ;
680+ const ABORTED_VIEW_TRANSITION_COMMIT = 1 ;
681+ const DELAYED_PASSIVE_COMMIT = 2 ;
682+ const ANIMATION_STARTED_COMMIT = 3 ;
683+
677684const NO_PENDING_EFFECTS = 0 ;
678685const PENDING_MUTATION_PHASE = 1 ;
679686const PENDING_LAYOUT_PHASE = 2 ;
@@ -696,6 +703,7 @@ let pendingViewTransitionEvents: Array<(types: Array<string>) => void> | null =
696703let pendingTransitionTypes : null | TransitionTypes = null ;
697704let pendingDidIncludeRenderPhaseUpdate : boolean = false ;
698705let pendingSuspendedCommitReason : SuspendedCommitReason = IMMEDIATE_COMMIT ; // Profiling-only
706+ let pendingDelayedCommitReason : DelayedCommitReason = IMMEDIATE_COMMIT ; // Profiling-only
699707
700708// Use these to prevent an infinite loop of nested updates
701709const NESTED_UPDATE_LIMIT = 50 ;
@@ -3436,6 +3444,7 @@ function commitRoot(
34363444 if ( enableProfilerTimer ) {
34373445 pendingEffectsRenderEndTime = completedRenderEndTime ;
34383446 pendingSuspendedCommitReason = suspendedCommitReason ;
3447+ pendingDelayedCommitReason = IMMEDIATE_COMMIT ;
34393448 }
34403449
34413450 if ( enableGestureTransition && isGestureRender ( lanes ) ) {
@@ -3495,7 +3504,10 @@ function commitRoot(
34953504 // event when logging events.
34963505 trackSchedulerEvent ( ) ;
34973506 }
3498- flushPassiveEffects ( true ) ;
3507+ if ( pendingDelayedCommitReason === IMMEDIATE_COMMIT ) {
3508+ pendingDelayedCommitReason = DELAYED_PASSIVE_COMMIT ;
3509+ }
3510+ flushPassiveEffects ( ) ;
34993511 // This render triggered passive effects: release the root cache pool
35003512 // *after* passive effects fire to avoid freeing a cache pool that may
35013513 // be referenced by a node in the tree (HostRoot, Cache boundary etc)
@@ -3736,6 +3748,23 @@ function flushLayoutEffects(): void {
37363748 ReactSharedInternals . T = prevTransition ;
37373749 }
37383750 }
3751+
3752+ const completedRenderEndTime = pendingEffectsRenderEndTime ;
3753+ const suspendedCommitReason = pendingSuspendedCommitReason ;
3754+
3755+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
3756+ recordCommitEndTime ( ) ;
3757+ logCommitPhase (
3758+ suspendedCommitReason === IMMEDIATE_COMMIT
3759+ ? completedRenderEndTime
3760+ : commitStartTime ,
3761+ commitEndTime ,
3762+ commitErrors ,
3763+ pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT ,
3764+ workInProgressUpdateTask ,
3765+ ) ;
3766+ }
3767+
37393768 pendingEffectsStatus = PENDING_AFTER_MUTATION_PHASE ;
37403769}
37413770
@@ -3748,6 +3777,25 @@ function flushSpawnedWork(): void {
37483777 ) {
37493778 return ;
37503779 }
3780+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
3781+ // If we didn't skip the after mutation phase, when is means we started an animation.
3782+ const startedAnimation = pendingEffectsStatus === PENDING_SPAWNED_WORK ;
3783+ if ( startedAnimation ) {
3784+ const startViewTransitionStartTime = commitEndTime ;
3785+ // Update the new commitEndTime to when we started the animation.
3786+ recordCommitEndTime ( ) ;
3787+ logStartViewTransitionYieldPhase (
3788+ startViewTransitionStartTime ,
3789+ commitEndTime ,
3790+ pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT ,
3791+ workInProgressUpdateTask , // TODO: Use a ViewTransition Task.
3792+ ) ;
3793+ if ( pendingDelayedCommitReason !== ABORTED_VIEW_TRANSITION_COMMIT ) {
3794+ pendingDelayedCommitReason = ANIMATION_STARTED_COMMIT ;
3795+ }
3796+ }
3797+ }
3798+
37513799 pendingEffectsStatus = NO_PENDING_EFFECTS ;
37523800
37533801 pendingViewTransition = null ; // The view transition has now fully started.
@@ -3759,22 +3807,8 @@ function flushSpawnedWork(): void {
37593807 const root = pendingEffectsRoot ;
37603808 const finishedWork = pendingFinishedWork ;
37613809 const lanes = pendingEffectsLanes ;
3762- const completedRenderEndTime = pendingEffectsRenderEndTime ;
37633810 const recoverableErrors = pendingRecoverableErrors ;
37643811 const didIncludeRenderPhaseUpdate = pendingDidIncludeRenderPhaseUpdate ;
3765- const suspendedCommitReason = pendingSuspendedCommitReason ;
3766-
3767- if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
3768- recordCommitEndTime ( ) ;
3769- logCommitPhase (
3770- suspendedCommitReason === IMMEDIATE_COMMIT
3771- ? completedRenderEndTime
3772- : commitStartTime ,
3773- commitEndTime ,
3774- commitErrors ,
3775- workInProgressUpdateTask ,
3776- ) ;
3777- }
37783812
37793813 const passiveSubtreeMask =
37803814 enableViewTransition && includesOnlyViewTransitionEligibleLanes ( lanes )
@@ -4141,7 +4175,14 @@ function releaseRootPooledCache(root: FiberRoot, remainingLanes: Lanes) {
41414175
41424176let didWarnAboutInterruptedViewTransitions = false ;
41434177
4144- export function flushPendingEffects ( wasDelayedCommit ?: boolean ) : boolean {
4178+ export function flushPendingEffectsDelayed ( ) : boolean {
4179+ if ( pendingDelayedCommitReason === IMMEDIATE_COMMIT ) {
4180+ pendingDelayedCommitReason = DELAYED_PASSIVE_COMMIT ;
4181+ }
4182+ return flushPendingEffects ( ) ;
4183+ }
4184+
4185+ export function flushPendingEffects ( ) : boolean {
41454186 // Returns whether passive effects were flushed.
41464187 if ( enableViewTransition && pendingViewTransition !== null ) {
41474188 // If we forced a flush before the View Transition full started then we skip it.
@@ -4159,17 +4200,18 @@ export function flushPendingEffects(wasDelayedCommit?: boolean): boolean {
41594200 }
41604201 }
41614202 pendingViewTransition = null ;
4203+ pendingDelayedCommitReason = ABORTED_VIEW_TRANSITION_COMMIT ;
41624204 }
41634205 flushGestureMutations ( ) ;
41644206 flushGestureAnimations ( ) ;
41654207 flushMutationEffects ( ) ;
41664208 flushLayoutEffects ( ) ;
41674209 // Skip flushAfterMutation if we're forcing this early.
41684210 flushSpawnedWork ( ) ;
4169- return flushPassiveEffects ( wasDelayedCommit ) ;
4211+ return flushPassiveEffects ( ) ;
41704212}
41714213
4172- function flushPassiveEffects ( wasDelayedCommit ?: boolean ) : boolean {
4214+ function flushPassiveEffects ( ) : boolean {
41734215 if ( pendingEffectsStatus !== PENDING_PASSIVE_PHASE ) {
41744216 return false ;
41754217 }
@@ -4194,7 +4236,7 @@ function flushPassiveEffects(wasDelayedCommit?: boolean): boolean {
41944236 try {
41954237 setCurrentUpdatePriority ( priority ) ;
41964238 ReactSharedInternals . T = null ;
4197- return flushPassiveEffectsImpl ( wasDelayedCommit ) ;
4239+ return flushPassiveEffectsImpl ( ) ;
41984240 } finally {
41994241 setCurrentUpdatePriority ( previousPriority ) ;
42004242 ReactSharedInternals . T = prevTransition ;
@@ -4206,7 +4248,7 @@ function flushPassiveEffects(wasDelayedCommit?: boolean): boolean {
42064248 }
42074249}
42084250
4209- function flushPassiveEffectsImpl ( wasDelayedCommit : void | boolean ) {
4251+ function flushPassiveEffectsImpl ( ) {
42104252 // Cache and clear the transitions flag
42114253 const transitions = pendingPassiveTransitions ;
42124254 pendingPassiveTransitions = null ;
@@ -4246,12 +4288,21 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) {
42464288 if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
42474289 resetCommitErrors ( ) ;
42484290 passiveEffectStartTime = now ( ) ;
4249- logPaintYieldPhase (
4250- commitEndTime ,
4251- passiveEffectStartTime ,
4252- ! ! wasDelayedCommit ,
4253- workInProgressUpdateTask ,
4254- ) ;
4291+ if ( pendingDelayedCommitReason === ANIMATION_STARTED_COMMIT ) {
4292+ // The animation was started, so we've been animating since that happened.
4293+ logAnimatingPhase (
4294+ commitEndTime ,
4295+ passiveEffectStartTime ,
4296+ workInProgressUpdateTask , // TODO: Use a ViewTransition Task
4297+ ) ;
4298+ } else {
4299+ logPaintYieldPhase (
4300+ commitEndTime ,
4301+ passiveEffectStartTime ,
4302+ pendingDelayedCommitReason === DELAYED_PASSIVE_COMMIT ,
4303+ workInProgressUpdateTask ,
4304+ ) ;
4305+ }
42554306 }
42564307
42574308 if ( enableSchedulingProfiler ) {
0 commit comments