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">
Sebastian Markbåge committed
Nov 21, 2024 at 19:36 UTC
91061073d57783c061889ac6720ef1ab7f0c2149
2 files changed
+23
packages/react-reconciler/src/ReactFiberWorkLoop.js
+5
@@ -269,6 +269,7 @@ import {
269
startYieldTimer,
270
yieldStartTime,
271
yieldReason,
272
+ startPingTimerByLanes,
273
} from './ReactProfilerTimer';
274
import {setCurrentTrackFromLanes} from './ReactFiberPerformanceTrack';
275
@@ -3961,6 +3962,10 @@ function pingSuspendedRoot(
3962
3963
markRootPinged(root, pingedLanes);
3964
3965
+ if (enableProfilerTimer && enableComponentPerformanceTrack) {
3966
+ startPingTimerByLanes(pingedLanes);
3967
+ }
3968
+
3969
warnIfSuspenseResolutionNotWrappedWithActDEV(root);
3970
3971
if (
packages/react-reconciler/src/ReactProfilerTimer.js
+18
@@ -108,6 +108,24 @@ export function startUpdateTimerByLane(lane: Lane): void {
108
}
109
}
110
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
+
129
export function trackSuspendedTime(lanes: Lanes, renderEndTime: number) {
130
if (!enableProfilerTimer || !enableComponentPerformanceTrack) {
131
return;