Skip to content

Commit

Permalink
Log passive commit phase when it wasn't delayed (#31526)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage authored Nov 14, 2024
1 parent 5d89471 commit 4686872
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 9 additions & 2 deletions packages/react-reconciler/src/ReactFiberPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}

Expand Down
10 changes: 6 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 4686872

Please sign in to comment.