Skip to content

Commit d3bf32a

Browse files
committed
Performance tracks are sorted by start time
To ensure that parent comes first we subtrack a little bit when we bubble the start time.
1 parent 9e06139 commit d3bf32a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/react-reconciler/src/ReactProfilerTimer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ function popComponentEffectStart(prevEffectStart: number): void {
9090
if (!enableProfilerTimer || !enableProfilerCommitHooks) {
9191
return;
9292
}
93-
// If the parent component didn't have a start time, we let this current time persist.
94-
if (prevEffectStart >= 0) {
93+
if (prevEffectStart < 0) {
94+
// If the parent component didn't have a start time, we use the start
95+
// of the child as the parent's start time. We subtrack a minimal amount of
96+
// time to ensure that the parent's start time is before the child to ensure
97+
// that the performance tracks line up in the right order.
98+
componentEffectStartTime -= 0.001;
99+
} else {
95100
// Otherwise, we restore the previous parent's start time.
96101
componentEffectStartTime = prevEffectStart;
97102
}

0 commit comments

Comments
 (0)