@@ -1029,9 +1029,18 @@ function completeUnitOfWork(workInProgress: Fiber): Fiber | null {
1029
1029
return null ;
1030
1030
}
1031
1031
} else {
1032
- if ( workInProgress . mode & ProfileMode ) {
1032
+ if ( enableProfilerTimer && workInProgress . mode & ProfileMode ) {
1033
1033
// Record the render duration for the fiber that errored.
1034
1034
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 ;
1035
1044
}
1036
1045
1037
1046
// This fiber did not complete because something threw. Pop values off
@@ -1056,19 +1065,6 @@ function completeUnitOfWork(workInProgress: Fiber): Fiber | null {
1056
1065
ReactFiberInstrumentation . debugTool . onCompleteWork ( workInProgress ) ;
1057
1066
}
1058
1067
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
-
1072
1068
// If completing this work spawned new work, do that next. We'll come
1073
1069
// back here again.
1074
1070
// Since we're restarting, remove anything that is not a host effect
@@ -1286,16 +1282,6 @@ function renderRoot(root: FiberRoot, isYieldy: boolean): void {
1286
1282
// Record the time spent rendering before an error was thrown.
1287
1283
// This avoids inaccurate Profiler durations in the case of a suspended render.
1288
1284
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
- }
1299
1285
}
1300
1286
1301
1287
if ( __DEV__ ) {
0 commit comments