@@ -69,6 +69,10 @@ import {
6969logBlockingStart ,
7070logTransitionStart ,
7171logRenderPhase ,
72+ logInterruptedRenderPhase ,
73+ logSuspendedRenderPhase ,
74+ logErroredRenderPhase ,
75+ logInconsistentRender ,
7276logSuspenseThrottlePhase ,
7377logSuspendedCommitPhase ,
7478logCommitPhase ,
@@ -255,6 +259,7 @@ import {
255259startProfilerTimer ,
256260stopProfilerTimerIfRunningAndRecordDuration ,
257261stopProfilerTimerIfRunningAndRecordIncompleteDuration ,
262+ markUpdateAsRepeat ,
258263} from './ReactProfilerTimer' ;
259264import { setCurrentTrackFromLanes } from './ReactFiberPerformanceTrack' ;
260265
@@ -955,6 +960,13 @@ export function performWorkOnRoot(
955960renderWasConcurrent &&
956961! isRenderConsistentWithExternalStores ( finishedWork )
957962) {
963+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
964+ setCurrentTrackFromLanes ( lanes ) ;
965+ const renderEndTime = now ( ) ;
966+ logInconsistentRender ( renderStartTime , renderEndTime ) ;
967+ finalizeRender ( lanes , renderEndTime ) ;
968+ markUpdateAsRepeat ( lanes ) ;
969+ }
958970// A store was mutated in an interleaved event. Render again,
959971// synchronously, to block further mutations.
960972exitStatus = renderRootSync ( root , lanes , false ) ;
@@ -976,6 +988,13 @@ export function performWorkOnRoot(
976988lanesThatJustErrored ,
977989) ;
978990if ( errorRetryLanes !== NoLanes ) {
991+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
992+ setCurrentTrackFromLanes ( lanes ) ;
993+ const renderEndTime = now ( ) ;
994+ logErroredRenderPhase ( renderStartTime , renderEndTime ) ;
995+ finalizeRender ( lanes , renderEndTime ) ;
996+ markUpdateAsRepeat ( lanes ) ;
997+ }
979998lanes = errorRetryLanes ;
980999exitStatus = recoverFromConcurrentError (
9811000root ,
@@ -999,6 +1018,12 @@ export function performWorkOnRoot(
9991018}
10001019}
10011020if ( exitStatus === RootFatalErrored ) {
1021+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1022+ setCurrentTrackFromLanes ( lanes ) ;
1023+ const renderEndTime = now ( ) ;
1024+ logErroredRenderPhase ( renderStartTime , renderEndTime ) ;
1025+ finalizeRender ( lanes , renderEndTime ) ;
1026+ }
10021027prepareFreshStack ( root , NoLanes ) ;
10031028// Since this is a fatal error, we're going to pretend we attempted
10041029// the entire tree, to avoid scheduling a prerender.
@@ -1136,6 +1161,8 @@ function finishConcurrentRender(
11361161// placeholder and without scheduling a timeout. Delay indefinitely
11371162// until we receive more data.
11381163if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1164+ setCurrentTrackFromLanes ( lanes ) ;
1165+ logSuspendedRenderPhase ( renderStartTime , renderEndTime ) ;
11391166finalizeRender ( lanes , renderEndTime ) ;
11401167}
11411168const didAttemptEntireTree = ! workInProgressRootDidSkipSuspendedSiblings ;
@@ -1180,6 +1207,7 @@ function finishConcurrentRender(
11801207workInProgressDeferredLane ,
11811208workInProgressRootInterleavedUpdatedLanes ,
11821209workInProgressSuspendedRetryLanes ,
1210+ exitStatus ,
11831211IMMEDIATE_COMMIT ,
11841212renderStartTime ,
11851213renderEndTime ,
@@ -1230,6 +1258,7 @@ function finishConcurrentRender(
12301258workInProgressRootInterleavedUpdatedLanes ,
12311259workInProgressSuspendedRetryLanes ,
12321260workInProgressRootDidSkipSuspendedSiblings ,
1261+ exitStatus ,
12331262THROTTLED_COMMIT ,
12341263renderStartTime ,
12351264renderEndTime ,
@@ -1250,6 +1279,7 @@ function finishConcurrentRender(
12501279workInProgressRootInterleavedUpdatedLanes ,
12511280workInProgressSuspendedRetryLanes ,
12521281workInProgressRootDidSkipSuspendedSiblings ,
1282+ exitStatus ,
12531283IMMEDIATE_COMMIT ,
12541284renderStartTime ,
12551285renderEndTime ,
@@ -1268,6 +1298,7 @@ function commitRootWhenReady(
12681298updatedLanes : Lanes ,
12691299suspendedRetryLanes : Lanes ,
12701300didSkipSuspendedSiblings : boolean ,
1301+ exitStatus : RootExitStatus ,
12711302suspendedCommitReason : SuspendedCommitReason , // Profiling-only
12721303completedRenderStartTime : number , // Profiling-only
12731304completedRenderEndTime : number , // Profiling-only
@@ -1311,6 +1342,7 @@ function commitRootWhenReady(
13111342spawnedLane ,
13121343updatedLanes ,
13131344suspendedRetryLanes ,
1345+ exitStatus ,
13141346SUSPENDED_COMMIT ,
13151347completedRenderStartTime ,
13161348completedRenderEndTime ,
@@ -1331,6 +1363,7 @@ function commitRootWhenReady(
13311363spawnedLane ,
13321364updatedLanes ,
13331365suspendedRetryLanes ,
1366+ exitStatus ,
13341367suspendedCommitReason ,
13351368completedRenderStartTime ,
13361369completedRenderEndTime ,
@@ -1649,13 +1682,21 @@ function finalizeRender(lanes: Lanes, finalizationTime: number): void {
16491682
16501683function prepareFreshStack ( root : FiberRoot , lanes : Lanes ) : Fiber {
16511684if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1685+ const previousRenderStartTime = renderStartTime ;
16521686// Starting a new render. Log the end of any previous renders and the
16531687// blocked time before the render started.
16541688recordRenderTime ( ) ;
16551689// If this was a restart, e.g. due to an interrupting update, then there's no space
16561690// in the track to log the cause since we'll have rendered all the way up until the
16571691// restart so we need to clamp that.
1658- finalizeRender ( workInProgressRootRenderLanes , renderStartTime ) ;
1692+ if (
1693+ workInProgressRootRenderLanes !== NoLanes &&
1694+ previousRenderStartTime > 0
1695+ ) {
1696+ setCurrentTrackFromLanes ( workInProgressRootRenderLanes ) ;
1697+ logInterruptedRenderPhase ( previousRenderStartTime , renderStartTime ) ;
1698+ finalizeRender ( workInProgressRootRenderLanes , renderStartTime ) ;
1699+ }
16591700
16601701if ( includesSyncLane ( lanes ) || includesBlockingLane ( lanes ) ) {
16611702logBlockingStart (
@@ -2983,6 +3024,7 @@ function commitRoot(
29833024spawnedLane : Lane ,
29843025updatedLanes : Lanes ,
29853026suspendedRetryLanes : Lanes ,
3027+ exitStatus : RootExitStatus ,
29863028suspendedCommitReason : SuspendedCommitReason , // Profiling-only
29873029completedRenderStartTime : number , // Profiling-only
29883030completedRenderEndTime : number , // Profiling-only
@@ -3003,6 +3045,7 @@ function commitRoot(
30033045spawnedLane ,
30043046updatedLanes ,
30053047suspendedRetryLanes ,
3048+ exitStatus ,
30063049suspendedCommitReason ,
30073050completedRenderStartTime ,
30083051completedRenderEndTime ,
@@ -3022,6 +3065,7 @@ function commitRootImpl(
30223065spawnedLane : Lane ,
30233066updatedLanes : Lanes ,
30243067suspendedRetryLanes : Lanes ,
3068+ exitStatus : RootExitStatus , // Profiling-only
30253069suspendedCommitReason : SuspendedCommitReason , // Profiling-only
30263070completedRenderStartTime : number , // Profiling-only
30273071completedRenderEndTime : number , // Profiling-only
@@ -3047,7 +3091,11 @@ function commitRootImpl(
30473091if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
30483092// Log the previous render phase once we commit. I.e. we weren't interrupted.
30493093setCurrentTrackFromLanes ( lanes ) ;
3050- logRenderPhase ( completedRenderStartTime , completedRenderEndTime ) ;
3094+ if ( exitStatus === RootErrored ) {
3095+ logErroredRenderPhase ( completedRenderStartTime , completedRenderEndTime ) ;
3096+ } else {
3097+ logRenderPhase ( completedRenderStartTime , completedRenderEndTime ) ;
3098+ }
30513099}
30523100
30533101if ( __DEV__ ) {
@@ -3409,7 +3457,7 @@ function commitRootImpl(
34093457
34103458if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
34113459if ( ! rootDidHavePassiveEffects ) {
3412- finalizeRender ( lanes , now ( ) ) ;
3460+ finalizeRender ( lanes , commitEndTime ) ;
34133461}
34143462}
34153463
0 commit comments