From 91061073d57783c061889ac6720ef1ab7f0c2149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Thu, 21 Nov 2024 19:36:38 -0500 Subject: [PATCH] Mark ping time as update (#31611) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Screenshot 2024-11-21 at 7 22 39 PM --- .../react-reconciler/src/ReactFiberWorkLoop.js | 5 +++++ .../react-reconciler/src/ReactProfilerTimer.js | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 9b452020375df..2ff35b0c6a7f2 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -269,6 +269,7 @@ import { startYieldTimer, yieldStartTime, yieldReason, + startPingTimerByLanes, } from './ReactProfilerTimer'; import {setCurrentTrackFromLanes} from './ReactFiberPerformanceTrack'; @@ -3961,6 +3962,10 @@ function pingSuspendedRoot( markRootPinged(root, pingedLanes); + if (enableProfilerTimer && enableComponentPerformanceTrack) { + startPingTimerByLanes(pingedLanes); + } + warnIfSuspenseResolutionNotWrappedWithActDEV(root); if ( diff --git a/packages/react-reconciler/src/ReactProfilerTimer.js b/packages/react-reconciler/src/ReactProfilerTimer.js index 2b20f45673e34..d408ba0ff7bd0 100644 --- a/packages/react-reconciler/src/ReactProfilerTimer.js +++ b/packages/react-reconciler/src/ReactProfilerTimer.js @@ -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;