Skip to content

Commit 37ab9da

Browse files
author
Brian Vaughn
committed
Moved actualDuration bubbling to completeUnitOfWork error branch
1 parent 7be6879 commit 37ab9da

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

packages/react-reconciler/src/ReactFiberScheduler.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,18 @@ function completeUnitOfWork(workInProgress: Fiber): Fiber | null {
10291029
return null;
10301030
}
10311031
} else {
1032-
if (workInProgress.mode & ProfileMode) {
1032+
if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
10331033
// Record the render duration for the fiber that errored.
10341034
stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
1035+
1036+
// Include the time spent working on failed children before continuing.
1037+
let actualDuration = workInProgress.actualDuration;
1038+
let child = workInProgress.child;
1039+
while (child !== null) {
1040+
actualDuration += child.actualDuration;
1041+
child = child.sibling;
1042+
}
1043+
workInProgress.actualDuration = actualDuration;
10351044
}
10361045

10371046
// This fiber did not complete because something threw. Pop values off
@@ -1056,19 +1065,6 @@ function completeUnitOfWork(workInProgress: Fiber): Fiber | null {
10561065
ReactFiberInstrumentation.debugTool.onCompleteWork(workInProgress);
10571066
}
10581067

1059-
if (enableProfilerTimer) {
1060-
// Include the time spent working on failed children before continuing.
1061-
if (next.mode & ProfileMode) {
1062-
let actualDuration = next.actualDuration;
1063-
let child = next.child;
1064-
while (child !== null) {
1065-
actualDuration += child.actualDuration;
1066-
child = child.sibling;
1067-
}
1068-
next.actualDuration = actualDuration;
1069-
}
1070-
}
1071-
10721068
// If completing this work spawned new work, do that next. We'll come
10731069
// back here again.
10741070
// Since we're restarting, remove anything that is not a host effect
@@ -1286,16 +1282,6 @@ function renderRoot(root: FiberRoot, isYieldy: boolean): void {
12861282
// Record the time spent rendering before an error was thrown.
12871283
// This avoids inaccurate Profiler durations in the case of a suspended render.
12881284
stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true);
1289-
1290-
// HACK Also propagate actualDuration for the time spent in the fiber that errored.
1291-
// This avoids inaccurate Profiler durations in the case of a suspended render.
1292-
// This happens automatically for sync renders, because of resetChildExpirationTime.
1293-
if (nextUnitOfWork.mode & ConcurrentMode) {
1294-
const returnFiber = nextUnitOfWork.return;
1295-
if (returnFiber !== null) {
1296-
returnFiber.actualDuration += nextUnitOfWork.actualDuration;
1297-
}
1298-
}
12991285
}
13001286

13011287
if (__DEV__) {

0 commit comments

Comments
 (0)