Refactor ReactProfilerTimer to Track Transition Timers Per Lane#35759
Open
subhamkumarr wants to merge 3 commits intofacebook:mainfrom
Open
Refactor ReactProfilerTimer to Track Transition Timers Per Lane#35759subhamkumarr wants to merge 3 commits intofacebook:mainfrom
ReactProfilerTimer to Track Transition Timers Per Lane#35759subhamkumarr wants to merge 3 commits intofacebook:mainfrom
Conversation
9a94135 to
06bebe9
Compare
06bebe9 to
8ed1e6e
Compare
Collaborator
|
Can you think of some tests to add (e.g. in |
Author
Done! I added a regression test in ReactTransitionTracing-test.js called It starts two transitions (at 1000ms and 2000ms) on separate roots and verifies they complete with their distinct start times, confirming they don't overwrite each other's global state. |
|
Okay that works
…On Tue, Feb 10, 2026 at 4:51 PM subham kumar ***@***.***> wrote:
Summary
This PR refactors ReactProfilerTimer.js to correctly track transition
timers on a per-lane basis, addressing a long-standing TODO (// TODO:
This should really be one per Transition lane.).
Previously, transition timings (start time, update time, event time) were
stored in global variables (transitionStartTime, transitionUpdateTime,
etc.). This caused issues when multiple transitions were being processed
concurrently or interleaved, as the global state could be overwritten,
leading to inaccurate profiling data.
Key Changes packages/react-reconciler/src/ReactProfilerTimer.js
- Replaced global transition timer variables with a transitionTimers
Map, keyed by Lane.
- Introduced WeakMaps (pendingTransitionStartTimes,
pendingTransitionEventInfo) to buffer timing data associated with a
Transition object before a specific Lane is assigned.
- Updated startUpdateTimerByLane, startHostActionTimer,
startAsyncTransitionTimer, and other helper functions to read/write
from the transitionTimers Map instead of global variables.
- Added getTransitionTimers(lane) to safely retrieve timer data for a
specific lane.
packages/react-reconciler/src/ReactFiberWorkLoop.js
- Updated the includesTransitionLane block in the work loop logic.
- It now iterates through all active transition lanes using
getHighestPriorityLane.
- For each lane, it retrieves the corresponding timer data and logs
the transition start/update.
- Ensures clearTransitionTimer(lane) is called for the specific lane
being processed, rather than a global clear.
Verification Automated Tests
- Passed yarn test
packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js
- Passed yarn test
packages/react-reconciler/src/__tests__/ReactPerformanceTrack-test.js
Manual Verification
- Verified that no regressions were introduced in basic profiling
behavior.
Related Issues
Fixes TODO in ReactProfilerTimer.js.
------------------------------
You can view, comment on, or merge this pull request online at:
#35759
Commit Summary
- 06bebe9
<06bebe9>
Refactor ReactProfilerTimer to track transition timers per lane
File Changes
(3 files <https://github.com/facebook/react/pull/35759/files>)
- *M* packages/react-reconciler/src/ReactFiberWorkLoop.js
<https://github.com/facebook/react/pull/35759/files#diff-72ff2175ae3569037f0b16802a41b0cda2b2d66bb97f2bda78ed8445ed487b58>
(307)
- *M* packages/react-reconciler/src/ReactProfilerTimer.js
<https://github.com/facebook/react/pull/35759/files#diff-c69c604b5395aa2edacdbb0665a529e3f483f02e5b2eb7a5e6ea063e5a60349e>
(247)
- *M* packages/react/src/ReactStartTransition.js
<https://github.com/facebook/react/pull/35759/files#diff-adb3f77f9697515adf24f3f32e9c3429635ca41d280f577a753ec4dbd0fa2fe0>
(10)
Patch Links:
- https://github.com/facebook/react/pull/35759.patch
- https://github.com/facebook/react/pull/35759.diff
—
Reply to this email directly, view it on GitHub
<#35759>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/B4CX3QANRCSDLJOPN5YDJ5L4LID6LAVCNFSM6AAAAACUULYF2GVHI2DSMVQWIX3LMV43ASLTON2WKOZTHEZDENBRG4ZTCNY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Thanks
…On Tue, Feb 10, 2026 at 4:52 PM subham kumar ***@***.***> wrote:
Summary
This PR refactors ReactProfilerTimer.js to correctly track transition
timers on a per-lane basis, addressing a long-standing TODO (// TODO:
This should really be one per Transition lane.).
Previously, transition timings (start time, update time, event time) were
stored in global variables (transitionStartTime, transitionUpdateTime,
etc.). This caused issues when multiple transitions were being processed
concurrently or interleaved, as the global state could be overwritten,
leading to inaccurate profiling data.
Key Changes packages/react-reconciler/src/ReactProfilerTimer.js
- Replaced global transition timer variables with a transitionTimers
Map, keyed by Lane.
- Introduced WeakMaps (pendingTransitionStartTimes,
pendingTransitionEventInfo) to buffer timing data associated with a
Transition object before a specific Lane is assigned.
- Updated startUpdateTimerByLane, startHostActionTimer,
startAsyncTransitionTimer, and other helper functions to read/write
from the transitionTimers Map instead of global variables.
- Added getTransitionTimers(lane) to safely retrieve timer data for a
specific lane.
packages/react-reconciler/src/ReactFiberWorkLoop.js
- Updated the includesTransitionLane block in the work loop logic.
- It now iterates through all active transition lanes using
getHighestPriorityLane.
- For each lane, it retrieves the corresponding timer data and logs
the transition start/update.
- Ensures clearTransitionTimer(lane) is called for the specific lane
being processed, rather than a global clear.
Verification Automated Tests
- Passed yarn test
packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js
- Passed yarn test
packages/react-reconciler/src/__tests__/ReactPerformanceTrack-test.js
Manual Verification
- Verified that no regressions were introduced in basic profiling
behavior.
Related Issues
Fixes TODO in ReactProfilerTimer.js.
------------------------------
You can view, comment on, or merge this pull request online at:
#35759
Commit Summary
- 06bebe9
<06bebe9>
Refactor ReactProfilerTimer to track transition timers per lane
File Changes
(3 files <https://github.com/facebook/react/pull/35759/files>)
- *M* packages/react-reconciler/src/ReactFiberWorkLoop.js
<https://github.com/facebook/react/pull/35759/files#diff-72ff2175ae3569037f0b16802a41b0cda2b2d66bb97f2bda78ed8445ed487b58>
(307)
- *M* packages/react-reconciler/src/ReactProfilerTimer.js
<https://github.com/facebook/react/pull/35759/files#diff-c69c604b5395aa2edacdbb0665a529e3f483f02e5b2eb7a5e6ea063e5a60349e>
(247)
- *M* packages/react/src/ReactStartTransition.js
<https://github.com/facebook/react/pull/35759/files#diff-adb3f77f9697515adf24f3f32e9c3429635ca41d280f577a753ec4dbd0fa2fe0>
(10)
Patch Links:
- https://github.com/facebook/react/pull/35759.patch
- https://github.com/facebook/react/pull/35759.diff
—
Reply to this email directly, view it on GitHub
<#35759>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/B4CX4CFUP2GLZI6FUCD6SED4LID6PAVCNFSM6AAAAACUULYF2GVHI2DSMVQWIX3LMV43ASLTON2WKOZTHEZDENBRG4ZTCNY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Author
|
@eps1lon |
Author
|
@hoxyq @eps1lon @unstubbable @jackpope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors
ReactProfilerTimer.jsto correctly track transition timers on a per-lane basis, addressing a long-standing TODO (// TODO: This should really be one per Transition lane.).Previously, transition timings (start time, update time, event time) were stored in global variables (
transitionStartTime,transitionUpdateTime, etc.). This caused issues when multiple transitions were being processed concurrently or interleaved, as the global state could be overwritten, leading to inaccurate profiling data.Key Changes
packages/react-reconciler/src/ReactProfilerTimer.jstransitionTimersMap, keyed byLane.WeakMaps (pendingTransitionStartTimes,pendingTransitionEventInfo) to buffer timing data associated with aTransitionobject before a specificLaneis assigned.startUpdateTimerByLane,startHostActionTimer,startAsyncTransitionTimer, and other helper functions to read/write from thetransitionTimersMap instead of global variables.getTransitionTimers(lane)to safely retrieve timer data for a specific lane.packages/react-reconciler/src/ReactFiberWorkLoop.jsincludesTransitionLaneblock in the work loop logic.getHighestPriorityLane.clearTransitionTimer(lane)is called for the specific lane being processed, rather than a global clear.Verification
Automated Tests
yarn test packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.jsyarn test packages/react-reconciler/src/__tests__/ReactPerformanceTrack-test.jsManual Verification
Related Issues
Fixes TODO in
ReactProfilerTimer.js.