@@ -245,11 +245,9 @@ import {
245
245
clampTransitionTimers ,
246
246
markNestedUpdateScheduled ,
247
247
renderStartTime ,
248
- renderEndTime ,
249
248
commitStartTime ,
250
249
commitEndTime ,
251
250
recordRenderTime ,
252
- recordCompleteTime ,
253
251
recordCommitTime ,
254
252
recordCommitEndTime ,
255
253
resetNestedUpdateFlag ,
@@ -611,6 +609,7 @@ let rootDoesHavePassiveEffects: boolean = false;
611
609
let rootWithPendingPassiveEffects : FiberRoot | null = null ;
612
610
let pendingPassiveEffectsLanes : Lanes = NoLanes ;
613
611
let pendingPassiveEffectsRemainingLanes : Lanes = NoLanes ;
612
+ let pendingPassiveEffectsRenderEndTime : number = - 0 ; // Profiling-only
614
613
let pendingPassiveTransitions : Array < Transition > | null = null ;
615
614
616
615
// Use these to prevent an infinite loop of nested updates
@@ -1129,10 +1128,11 @@ function finishConcurrentRender(
1129
1128
finishedWork : Fiber ,
1130
1129
lanes : Lanes ,
1131
1130
) {
1131
+ let renderEndTime = 0 ;
1132
1132
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1133
1133
// Track when we finished the last unit of work, before we actually commit it.
1134
1134
// The commit can be suspended/blocked until we commit it.
1135
- recordCompleteTime ( ) ;
1135
+ renderEndTime = now ( ) ;
1136
1136
setCurrentTrackFromLanes ( lanes ) ;
1137
1137
logRenderPhase ( renderStartTime , renderEndTime ) ;
1138
1138
}
@@ -1195,6 +1195,8 @@ function finishConcurrentRender(
1195
1195
workInProgressRootInterleavedUpdatedLanes ,
1196
1196
workInProgressSuspendedRetryLanes ,
1197
1197
IMMEDIATE_COMMIT ,
1198
+ renderStartTime ,
1199
+ renderEndTime ,
1198
1200
) ;
1199
1201
} else {
1200
1202
if (
@@ -1241,6 +1243,8 @@ function finishConcurrentRender(
1241
1243
workInProgressSuspendedRetryLanes ,
1242
1244
workInProgressRootDidSkipSuspendedSiblings ,
1243
1245
THROTTLED_COMMIT ,
1246
+ renderStartTime ,
1247
+ renderEndTime ,
1244
1248
) ,
1245
1249
msUntilTimeout ,
1246
1250
) ;
@@ -1259,6 +1263,8 @@ function finishConcurrentRender(
1259
1263
workInProgressSuspendedRetryLanes ,
1260
1264
workInProgressRootDidSkipSuspendedSiblings ,
1261
1265
IMMEDIATE_COMMIT ,
1266
+ renderStartTime ,
1267
+ renderEndTime ,
1262
1268
) ;
1263
1269
}
1264
1270
}
@@ -1274,7 +1280,9 @@ function commitRootWhenReady(
1274
1280
updatedLanes : Lanes ,
1275
1281
suspendedRetryLanes : Lanes ,
1276
1282
didSkipSuspendedSiblings : boolean ,
1277
- suspendedCommitReason : SuspendedCommitReason ,
1283
+ suspendedCommitReason : SuspendedCommitReason , // Profiling-only
1284
+ completedRenderStartTime : number , // Profiling-only
1285
+ completedRenderEndTime : number , // Profiling-only
1278
1286
) {
1279
1287
// TODO: Combine retry throttling with Suspensey commits. Right now they run
1280
1288
// one after the other.
@@ -1333,6 +1341,8 @@ function commitRootWhenReady(
1333
1341
updatedLanes ,
1334
1342
suspendedRetryLanes ,
1335
1343
suspendedCommitReason ,
1344
+ completedRenderStartTime ,
1345
+ completedRenderEndTime ,
1336
1346
) ;
1337
1347
}
1338
1348
@@ -1524,8 +1534,9 @@ export function performSyncWorkOnRoot(root: FiberRoot, lanes: Lanes): null {
1524
1534
return null ;
1525
1535
}
1526
1536
1537
+ let renderEndTime = 0 ;
1527
1538
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1528
- recordCompleteTime ( ) ;
1539
+ renderEndTime = now ( ) ;
1529
1540
setCurrentTrackFromLanes ( lanes ) ;
1530
1541
logRenderPhase ( renderStartTime , renderEndTime ) ;
1531
1542
}
@@ -1544,6 +1555,8 @@ export function performSyncWorkOnRoot(root: FiberRoot, lanes: Lanes): null {
1544
1555
workInProgressRootInterleavedUpdatedLanes ,
1545
1556
workInProgressSuspendedRetryLanes ,
1546
1557
IMMEDIATE_COMMIT ,
1558
+ renderStartTime ,
1559
+ renderEndTime ,
1547
1560
) ;
1548
1561
1549
1562
// Before exiting, make sure there's a callback scheduled for the next
@@ -3050,7 +3063,9 @@ function commitRoot(
3050
3063
spawnedLane : Lane ,
3051
3064
updatedLanes : Lanes ,
3052
3065
suspendedRetryLanes : Lanes ,
3053
- suspendedCommitReason : SuspendedCommitReason ,
3066
+ suspendedCommitReason : SuspendedCommitReason , // Profiling-only
3067
+ completedRenderStartTime : number , // Profiling-only
3068
+ completedRenderEndTime : number , // Profiling-only
3054
3069
) {
3055
3070
// TODO: This no longer makes any sense. We already wrap the mutation and
3056
3071
// layout phases. Should be able to remove.
@@ -3069,6 +3084,8 @@ function commitRoot(
3069
3084
updatedLanes ,
3070
3085
suspendedRetryLanes ,
3071
3086
suspendedCommitReason ,
3087
+ completedRenderStartTime ,
3088
+ completedRenderEndTime ,
3072
3089
) ;
3073
3090
} finally {
3074
3091
ReactSharedInternals . T = prevTransition ;
@@ -3087,7 +3104,9 @@ function commitRootImpl(
3087
3104
spawnedLane : Lane ,
3088
3105
updatedLanes : Lanes ,
3089
3106
suspendedRetryLanes : Lanes ,
3090
- suspendedCommitReason : SuspendedCommitReason ,
3107
+ suspendedCommitReason : SuspendedCommitReason , // Profiling-only
3108
+ completedRenderStartTime : number , // Profiling-only
3109
+ completedRenderEndTime : number , // Profiling-only
3091
3110
) {
3092
3111
do {
3093
3112
// `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
@@ -3203,6 +3222,7 @@ function commitRootImpl(
3203
3222
if ( ! rootDoesHavePassiveEffects ) {
3204
3223
rootDoesHavePassiveEffects = true ;
3205
3224
pendingPassiveEffectsRemainingLanes = remainingLanes ;
3225
+ pendingPassiveEffectsRenderEndTime = completedRenderEndTime ;
3206
3226
// workInProgressTransitions might be overwritten, so we want
3207
3227
// to store it in pendingPassiveTransitions until they get processed
3208
3228
// We need to pass this through as an argument to commitRoot
@@ -3226,9 +3246,9 @@ function commitRootImpl(
3226
3246
recordCommitTime ( ) ;
3227
3247
if ( enableComponentPerformanceTrack ) {
3228
3248
if ( suspendedCommitReason === SUSPENDED_COMMIT ) {
3229
- logSuspendedCommitPhase ( renderEndTime , commitStartTime ) ;
3249
+ logSuspendedCommitPhase ( completedRenderEndTime , commitStartTime ) ;
3230
3250
} else if ( suspendedCommitReason === THROTTLED_COMMIT ) {
3231
- logSuspenseThrottlePhase ( renderEndTime , commitStartTime ) ;
3251
+ logSuspenseThrottlePhase ( completedRenderEndTime , commitStartTime ) ;
3232
3252
}
3233
3253
}
3234
3254
}
@@ -3628,7 +3648,13 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) {
3628
3648
executionContext |= CommitContext ;
3629
3649
3630
3650
commitPassiveUnmountEffects ( root . current ) ;
3631
- commitPassiveMountEffects ( root , root . current , lanes , transitions ) ;
3651
+ commitPassiveMountEffects (
3652
+ root ,
3653
+ root . current ,
3654
+ lanes ,
3655
+ transitions ,
3656
+ pendingPassiveEffectsRenderEndTime ,
3657
+ ) ;
3632
3658
3633
3659
if ( __DEV__ ) {
3634
3660
if ( enableDebugTracing ) {
0 commit comments