Skip to content

Commit 9106107

Browse files
authored
Mark ping time as update (#31611)
This ensures that we mark the time from ping until we render as "Blocked". We intentionally don't want to show the event time even if it's something like "load" because it draws attention away from interactions etc. <img width="577" alt="Screenshot 2024-11-21 at 7 22 39 PM" src="https://github.com/user-attachments/assets/70cca2e8-bd5e-489f-98f0-b4dfee5940af">
1 parent a9f14cb commit 9106107

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

+5
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ import {
269269
startYieldTimer,
270270
yieldStartTime,
271271
yieldReason,
272+
startPingTimerByLanes,
272273
} from './ReactProfilerTimer';
273274
import {setCurrentTrackFromLanes} from './ReactFiberPerformanceTrack';
274275

@@ -3961,6 +3962,10 @@ function pingSuspendedRoot(
39613962

39623963
markRootPinged(root, pingedLanes);
39633964

3965+
if (enableProfilerTimer && enableComponentPerformanceTrack) {
3966+
startPingTimerByLanes(pingedLanes);
3967+
}
3968+
39643969
warnIfSuspenseResolutionNotWrappedWithActDEV(root);
39653970

39663971
if (

packages/react-reconciler/src/ReactProfilerTimer.js

+18
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ export function startUpdateTimerByLane(lane: Lane): void {
108108
}
109109
}
110110

111+
export function startPingTimerByLanes(lanes: Lanes): void {
112+
if (!enableProfilerTimer || !enableComponentPerformanceTrack) {
113+
return;
114+
}
115+
// Mark the update time and clamp anything before it because we don't want
116+
// to show the event time for pings but we also don't want to clear it
117+
// because we still need to track if this was a repeat.
118+
if (includesSyncLane(lanes) || includesBlockingLane(lanes)) {
119+
if (blockingUpdateTime < 0) {
120+
blockingClampTime = blockingUpdateTime = now();
121+
}
122+
} else if (includesTransitionLane(lanes)) {
123+
if (transitionUpdateTime < 0) {
124+
transitionClampTime = transitionUpdateTime = now();
125+
}
126+
}
127+
}
128+
111129
export function trackSuspendedTime(lanes: Lanes, renderEndTime: number) {
112130
if (!enableProfilerTimer || !enableComponentPerformanceTrack) {
113131
return;

0 commit comments

Comments
 (0)