From 4686872159e357accd092b195fb5cafceb980ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Thu, 14 Nov 2024 16:30:05 -0500 Subject: [PATCH] Log passive commit phase when it wasn't delayed (#31526) Fixes a bug. We're supposed to not log "Waiting for Paint" if the passive effect phase was forced since we weren't really waiting until the paint. Instead we just log an empty string when we force it to still ensure continuity. We should always log the passive phase. This check was in the wrong place. --- .../src/ReactFiberPerformanceTrack.js | 11 +++++++++-- packages/react-reconciler/src/ReactFiberWorkLoop.js | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js index b80635423ab5f..e1d75149b2425 100644 --- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js +++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js @@ -221,12 +221,19 @@ export function logCommitPhase(startTime: number, endTime: number): void { } } -export function logPaintYieldPhase(startTime: number, endTime: number): void { +export function logPaintYieldPhase( + startTime: number, + endTime: number, + delayedUntilPaint: boolean, +): void { if (supportsUserTiming) { reusableLaneDevToolDetails.color = 'secondary-light'; reusableLaneOptions.start = startTime; reusableLaneOptions.end = endTime; - performance.measure('Waiting for Paint', reusableLaneOptions); + performance.measure( + delayedUntilPaint ? 'Waiting for Paint' : '', + reusableLaneOptions, + ); } } diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index bffedf498bc28..6d2ec2d0c8e61 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -3550,7 +3550,11 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) { let passiveEffectStartTime = 0; if (enableProfilerTimer && enableComponentPerformanceTrack) { passiveEffectStartTime = now(); - logPaintYieldPhase(commitEndTime, passiveEffectStartTime); + logPaintYieldPhase( + commitEndTime, + passiveEffectStartTime, + !!wasDelayedCommit, + ); } if (enableSchedulingProfiler) { @@ -3587,9 +3591,7 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) { if (enableProfilerTimer && enableComponentPerformanceTrack) { const passiveEffectsEndTime = now(); - if (wasDelayedCommit) { - logPassiveCommitPhase(passiveEffectStartTime, passiveEffectsEndTime); - } + logPassiveCommitPhase(passiveEffectStartTime, passiveEffectsEndTime); finalizeRender(lanes, passiveEffectsEndTime); }