Skip to content

Commit 108aae1

Browse files
committed
Clamp prelude if it was an interruption
I.e. the currently on-going render was the same track.
1 parent bddab05 commit 108aae1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,9 +1716,8 @@ function resetWorkInProgressStack() {
17161716
workInProgress = null;
17171717
}
17181718

1719-
function finalizeRender(lanes: Lanes): void {
1719+
function finalizeRender(lanes: Lanes, finalizationTime: number): void {
17201720
if (enableProfilerTimer && enableComponentPerformanceTrack) {
1721-
const finalizationTime = now();
17221721
if (includesBlockingLane(lanes)) {
17231722
clampBlockingTimers(finalizationTime);
17241723
}
@@ -1733,6 +1732,11 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes): Fiber {
17331732
// Starting a new render. Log the end of any previous renders and the
17341733
// blocked time before the render started.
17351734
recordRenderTime();
1735+
// If this was a restart, e.g. due to an interrupting update, then there's no space
1736+
// in the track to log the cause since we'll have rendered all the way up until the
1737+
// restart so we need to clamp that.
1738+
finalizeRender(workInProgressRootRenderLanes, renderStartTime);
1739+
17361740
if (includesBlockingLane(lanes)) {
17371741
logBlockingStart(
17381742
blockingUpdateTime,
@@ -3414,8 +3418,10 @@ function commitRootImpl(
34143418
nestedUpdateCount = 0;
34153419
}
34163420

3417-
if (!rootDidHavePassiveEffects) {
3418-
finalizeRender(lanes);
3421+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
3422+
if (!rootDidHavePassiveEffects) {
3423+
finalizeRender(lanes, now());
3424+
}
34193425
}
34203426

34213427
// If layout work was scheduled, flush it now.
@@ -3599,7 +3605,9 @@ function flushPassiveEffectsImpl() {
35993605

36003606
executionContext = prevExecutionContext;
36013607

3602-
finalizeRender(lanes);
3608+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
3609+
finalizeRender(lanes, now());
3610+
}
36033611

36043612
flushSyncWorkOnAllRoots();
36053613

0 commit comments

Comments
 (0)