Skip to content

Commit

Permalink
Mark ping time as update
Browse files Browse the repository at this point in the history
This ensures that we mark the time from ping until we render as "Blocked".

We intentionally don't want to show the event time.
  • Loading branch information
sebmarkbage committed Nov 22, 2024
1 parent a9f14cb commit 9bb7e9e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ import {
startYieldTimer,
yieldStartTime,
yieldReason,
startPingTimerByLanes,
} from './ReactProfilerTimer';
import {setCurrentTrackFromLanes} from './ReactFiberPerformanceTrack';

Expand Down Expand Up @@ -3961,6 +3962,10 @@ function pingSuspendedRoot(

markRootPinged(root, pingedLanes);

if (enableProfilerTimer && enableComponentPerformanceTrack) {
startPingTimerByLanes(pingedLanes);
}

warnIfSuspenseResolutionNotWrappedWithActDEV(root);

if (
Expand Down
18 changes: 18 additions & 0 deletions packages/react-reconciler/src/ReactProfilerTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ export function startUpdateTimerByLane(lane: Lane): void {
}
}

export function startPingTimerByLanes(lanes: Lanes): void {
if (!enableProfilerTimer || !enableComponentPerformanceTrack) {
return;
}
// Mark the update time and clamp anything before it because we don't want
// to show the event time for pings but we also don't want to clear it
// because we still need to track if this was a repeat.
if (includesSyncLane(lanes) || includesBlockingLane(lanes)) {
if (blockingUpdateTime < 0) {
blockingClampTime = blockingUpdateTime = now();
}
} else if (includesTransitionLane(lanes)) {
if (transitionUpdateTime < 0) {
transitionClampTime = transitionUpdateTime = now();
}
}
}

export function trackSuspendedTime(lanes: Lanes, renderEndTime: number) {
if (!enableProfilerTimer || !enableComponentPerformanceTrack) {
return;
Expand Down

0 comments on commit 9bb7e9e

Please sign in to comment.