Skip to content

Commit 3da0519

Browse files
committed
Unify renderEndTime
1 parent 3720870 commit 3da0519

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,11 @@ export function performWorkOnRoot(
948948
}
949949
break;
950950
} else {
951+
let renderEndTime = 0;
952+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
953+
renderEndTime = now();
954+
}
955+
951956
// The render completed.
952957

953958
// Check if this render may have yielded to a concurrent event, and if so,
@@ -962,7 +967,6 @@ export function performWorkOnRoot(
962967
) {
963968
if (enableProfilerTimer && enableComponentPerformanceTrack) {
964969
setCurrentTrackFromLanes(lanes);
965-
const renderEndTime = now();
966970
logInconsistentRender(renderStartTime, renderEndTime);
967971
finalizeRender(lanes, renderEndTime);
968972
markUpdateAsRepeat(lanes);
@@ -990,7 +994,6 @@ export function performWorkOnRoot(
990994
if (errorRetryLanes !== NoLanes) {
991995
if (enableProfilerTimer && enableComponentPerformanceTrack) {
992996
setCurrentTrackFromLanes(lanes);
993-
const renderEndTime = now();
994997
logErroredRenderPhase(renderStartTime, renderEndTime);
995998
finalizeRender(lanes, renderEndTime);
996999
markUpdateAsRepeat(lanes);
@@ -1014,13 +1017,15 @@ export function performWorkOnRoot(
10141017
continue;
10151018
} else {
10161019
// The root errored yet again. Proceed to commit the tree.
1020+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
1021+
renderEndTime = now();
1022+
}
10171023
}
10181024
}
10191025
}
10201026
if (exitStatus === RootFatalErrored) {
10211027
if (enableProfilerTimer && enableComponentPerformanceTrack) {
10221028
setCurrentTrackFromLanes(lanes);
1023-
const renderEndTime = now();
10241029
logErroredRenderPhase(renderStartTime, renderEndTime);
10251030
finalizeRender(lanes, renderEndTime);
10261031
}
@@ -1034,7 +1039,13 @@ export function performWorkOnRoot(
10341039

10351040
// We now have a consistent tree. The next step is either to commit it,
10361041
// or, if something suspended, wait to commit it after a timeout.
1037-
finishConcurrentRender(root, exitStatus, finishedWork, lanes);
1042+
finishConcurrentRender(
1043+
root,
1044+
exitStatus,
1045+
finishedWork,
1046+
lanes,
1047+
renderEndTime,
1048+
);
10381049
}
10391050
break;
10401051
} while (true);
@@ -1133,14 +1144,8 @@ function finishConcurrentRender(
11331144
exitStatus: RootExitStatus,
11341145
finishedWork: Fiber,
11351146
lanes: Lanes,
1147+
renderEndTime: number // Profiling-only
11361148
) {
1137-
let renderEndTime = 0;
1138-
if (enableProfilerTimer && enableComponentPerformanceTrack) {
1139-
// Track when we finished the last unit of work, before we actually commit it.
1140-
// The commit can be suspended/blocked until we commit it.
1141-
renderEndTime = now();
1142-
}
1143-
11441149
// TODO: The fact that most of these branches are identical suggests that some
11451150
// of the exit statuses are not best modeled as exit statuses and should be
11461151
// tracked orthogonally.

0 commit comments

Comments
 (0)