GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Transition Tracing] Add Support for Multiple Transitions on Root by lunaruan · Pull Request #24732 · react/react

Conversation

@lunaruan

@lunaruan lunaruan commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

We can think of transitions on the root as a bunch of tracing markers. Therefore, we can map each transition to a map of pending suspense boundaries. When a transition's pending suspense boundary map is empty, we know that it's complete. This PR:

  • Combines the pendingSuspenseBoundaries and transitions into one incompleteTransitions object. This object is a map from a transition to a map of pendingSuspenseBoundaries
  • Refactored code to make it so that every transition has its own pendingSuspenseBoundaries map rather than sharing just one.
  • Moves the transition complete callback to the root. Alternatively, we can also keep a map of pendingSuspenseBoundaries to transitions on the Offscreen marker, but it's simpler to just call the transition complete callback on the root instead. We also only do this if there are transitions pending, so it shouldn't make too big of a difference

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lunaruan
lunaruan requested a review from acdlite June 15, 2022 23:04
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 15, 2022
@lunaruan
lunaruan force-pushed the multiple_roots branch from faba079 to a51ea81 Compare June 15, 2022 23:05
@sizebot

sizebot commented Jun 15, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: fcd720d...dd962d3

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 131.76 kB 131.64 kB = 42.31 kB 42.30 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 137.03 kB 136.92 kB = 43.90 kB 43.89 kB
facebook-www/ReactDOM-prod.classic.js = 440.91 kB 440.67 kB = 80.63 kB 80.59 kB
facebook-www/ReactDOM-prod.modern.js = 426.21 kB 425.98 kB = 78.44 kB 78.41 kB
facebook-www/ReactDOMForked-prod.classic.js = 441.61 kB 441.38 kB = 80.85 kB 80.81 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against dd962d3

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lunaruan
lunaruan force-pushed the multiple_roots branch from a51ea81 to da4ed39 Compare June 16, 2022 01:59
lunaruan
lunaruan commented Jun 16, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.old.js Outdated
const rootPendingBoundaries = rootState.pendingSuspenseBoundaries;
const rootTransitions = rootState.transitions;

const suspenseBoundaries = (offscreenFiber.updateQueue: any).markers;

@lunaruan lunaruan Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lunaruan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
lunaruan
lunaruan commented Jun 16, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Outdated
queue.markers = new Set();
}
if (transitions !== null && prevTransitions === null) {
finishedWork.memoizedState.transitions = prevTransitions = new Set();

@lunaruan lunaruan Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move markers and transitions to the instance

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lunaruan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@lunaruan lunaruan Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also move everything to root

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lunaruan
lunaruan commented Jun 16, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js Outdated
});

// @gate enableTransitionTracing
it('should correctly trace multiple root interactions', async () => {

@lunaruan lunaruan Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write another test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lunaruan
lunaruan force-pushed the multiple_roots branch from da4ed39 to 82cc491 Compare June 17, 2022 18:32
lunaruan
lunaruan commented Jun 17, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Outdated
queue.markers = new Set();
}
if (transitions !== null && prevTransitions === null) {
finishedWork.memoizedState.transitions = prevTransitions = new Set();

@lunaruan lunaruan Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also move everything to root

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js
const pendingTransitions = state.transitions;
const pendingSuspenseBoundaries = state.pendingSuspenseBoundaries;

let incompleteTransitions = state.incompleteTransitions;

@lunaruan lunaruan Jun 17, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move this code to the HostRoot in a separate PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lunaruan
lunaruan force-pushed the multiple_roots branch from 82cc491 to 50f7435 Compare June 17, 2022 19:00
lunaruan added 2 commits June 17, 2022 15:08
@lunaruan
add support for multiple roots
74debbf
@lunaruan
old
e8bf4f6
@lunaruan
lunaruan force-pushed the multiple_roots branch from 50f7435 to e8bf4f6 Compare June 17, 2022 19:08
acdlite
acdlite approved these changes Jun 17, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberBeginWork.new.js Outdated
if (currentTransitions !== null) {
const primaryChildUpdateQueue: OffscreenQueue = {
transitions: currentTransitions,
markers: null,

@acdlite acdlite Jun 16, 2022

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this yet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/react-reconciler/src/ReactFiberBeginWork.new.js Outdated
// be added to the stack to get added to any Offscreen/suspense children
transitions = workInProgress.memoizedState.transitions;
if (enableTransitionTracing) {
if (workInProgress.stateNode.transitions !== null) {

@acdlite acdlite Jun 17, 2022

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to check if it's null, right? It can just pass through

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js
// and sets in the commit phase as we need to use them. We only
// instantiate them in the fallback phase on an as needed basis
if (rootMemoizedState.incompleteTransitions === null) {
rootMemoizedState.incompleteTransitions = rootIncompleteTransitions = new Map();

@acdlite acdlite Jun 17, 2022

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a TODO here to move this to the FiberRoot?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lunaruan added 2 commits June 17, 2022 16:27
@lunaruan
fixed nits
0d186bb
@lunaruan
fixed nits old
dd962d3
@lunaruan
lunaruan merged commit 12a738f into react:main Jun 17, 2022
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Sep 6, 2022
@sammy-SC @facebook-github-bot
React Native sync for revisions 229c86a...c1f5884
37d0a25
Summary:
This sync includes the following changes:
- **[c1f5884](react/react@c1f5884ff )**: Add missing null checks to OffscreenInstance code ([#24846](react/react#24846)) //<Andrew Clark>//
- **[4cd788a](react/react@4cd788aef )**: Revert "Revert [Transition Tracing] Refactor Transition Tracing Root Code" ([#24830](react/react#24830)) //<Luna Ruan>//
- **[e61fd91](react/react@e61fd91f5 )**: Revert "[Transition Tracing] Refactor Transition Tracing Root Code ([#24766](react/react#24766))" ([#24829](react/react#24829)) //<Andrew Clark>//
- **[4012963](react/react@401296310 )**: [Transition Tracing] Refactor Transition Tracing Root Code ([#24766](react/react#24766)) //<Luna Ruan>//
- **[1859329](react/react@185932902 )**: Track nearest Suspense handler on stack ([#24585](react/react#24585)) //<Andrew Clark>//
- **[a7b192e](react/react@a7b192e0f )**: Add test gate alias for Offscreen ([#24749](react/react#24749)) //<Andrew Clark>//
- **[6b6cf83](react/react@6b6cf8311 )**: Land forked reconciler changes ([#24817](react/react#24817)) //<Andrew Clark>//
- **[d1432ba](react/react@d1432ba93 )**: [Transition Tracing] Fix excess calls to the transition start callback ([#24806](react/react#24806)) //<Luna Ruan>//
- **[88574c1](react/react@88574c1b8 )**: Fix enableTransitionTracing flag ([#24801](react/react#24801)) //<Luna Ruan>//
- **[a4bed46](react/react@a4bed4696 )**: [Transition Tracing] Add Tracing Markers ([#24686](react/react#24686)) //<Luna Ruan>//
- **[1678530](react/react@167853026 )**: fix hydration warning suppression in text comparisons ([#24784](react/react#24784)) //<Josh Story>//
- **[9abe745](react/react@9abe745aa )**: [DevTools][Timeline Profiler] Component Stacks Backend ([#24776](react/react#24776)) //<Luna Ruan>//
- **[cf665c4](react/react@cf665c4b7 )**: [DevTools] Refactor incompleteTransitions field from Root Fiber memoized state to FiberRoot ([#24765](react/react#24765)) //<Luna Ruan>//
- **[56389e8](react/react@56389e81f )**: Abort Flight ([#24754](react/react#24754)) //<Sebastian Markbåge>//
- **[0f216ae](react/react@0f216ae31 )**: Add entry points for "static" server rendering passes ([#24752](react/react#24752)) //<Sebastian Markbåge>//
- **[f796fa1](react/react@f796fa13a )**: Rename Segment to Task in Flight ([#24753](react/react#24753)) //<Sebastian Markbåge>//
- **[0f0aca3](react/react@0f0aca3ab )**: Aborting early should not infinitely suspend ([#24751](react/react#24751)) //<Sebastian Markbåge>//
- **[12a738f](react/react@12a738f1a )**: [Transition Tracing] Add Support for Multiple Transitions on Root ([#24732](react/react#24732)) //<Luna Ruan>//
- **[72ebc70](react/react@72ebc703a )**: [DevTools] fix useDeferredValue to match reconciler change ([#24742](react/react#24742)) //<Mengdi Chen>//
- **[7cf9f5e](react/react@7cf9f5e03 )**: Extra space ([#24612](react/react#24612)) //<Kerim Büyükakyüz>//

Changelog:
[General][Changed] - React Native sync for revisions 229c86a...c1f5884

Reviewed By: mdvacca, GijsWeterings

Differential Revision: D38904311

fbshipit-source-id: 1e30bc420c30ec7a0c0073fc92a706afef4b3340
cipolleschi pushed a commit to react/react-native that referenced this pull request Sep 7, 2022
@sammy-SC Riccardo Cipolleschi
React Native sync for revisions 229c86a...c1f5884
d9cd5a5
Summary:
This sync includes the following changes:
- **[c1f5884](react/react@c1f5884ff )**: Add missing null checks to OffscreenInstance code ([#24846](react/react#24846)) //<Andrew Clark>//
- **[4cd788a](react/react@4cd788aef )**: Revert "Revert [Transition Tracing] Refactor Transition Tracing Root Code" ([#24830](react/react#24830)) //<Luna Ruan>//
- **[e61fd91](react/react@e61fd91f5 )**: Revert "[Transition Tracing] Refactor Transition Tracing Root Code ([#24766](react/react#24766))" ([#24829](react/react#24829)) //<Andrew Clark>//
- **[4012963](react/react@401296310 )**: [Transition Tracing] Refactor Transition Tracing Root Code ([#24766](react/react#24766)) //<Luna Ruan>//
- **[1859329](react/react@185932902 )**: Track nearest Suspense handler on stack ([#24585](react/react#24585)) //<Andrew Clark>//
- **[a7b192e](react/react@a7b192e0f )**: Add test gate alias for Offscreen ([#24749](react/react#24749)) //<Andrew Clark>//
- **[6b6cf83](react/react@6b6cf8311 )**: Land forked reconciler changes ([#24817](react/react#24817)) //<Andrew Clark>//
- **[d1432ba](react/react@d1432ba93 )**: [Transition Tracing] Fix excess calls to the transition start callback ([#24806](react/react#24806)) //<Luna Ruan>//
- **[88574c1](react/react@88574c1b8 )**: Fix enableTransitionTracing flag ([#24801](react/react#24801)) //<Luna Ruan>//
- **[a4bed46](react/react@a4bed4696 )**: [Transition Tracing] Add Tracing Markers ([#24686](react/react#24686)) //<Luna Ruan>//
- **[1678530](react/react@167853026 )**: fix hydration warning suppression in text comparisons ([#24784](react/react#24784)) //<Josh Story>//
- **[9abe745](react/react@9abe745aa )**: [DevTools][Timeline Profiler] Component Stacks Backend ([#24776](react/react#24776)) //<Luna Ruan>//
- **[cf665c4](react/react@cf665c4b7 )**: [DevTools] Refactor incompleteTransitions field from Root Fiber memoized state to FiberRoot ([#24765](react/react#24765)) //<Luna Ruan>//
- **[56389e8](react/react@56389e81f )**: Abort Flight ([#24754](react/react#24754)) //<Sebastian Markbåge>//
- **[0f216ae](react/react@0f216ae31 )**: Add entry points for "static" server rendering passes ([#24752](react/react#24752)) //<Sebastian Markbåge>//
- **[f796fa1](react/react@f796fa13a )**: Rename Segment to Task in Flight ([#24753](react/react#24753)) //<Sebastian Markbåge>//
- **[0f0aca3](react/react@0f0aca3ab )**: Aborting early should not infinitely suspend ([#24751](react/react#24751)) //<Sebastian Markbåge>//
- **[12a738f](react/react@12a738f1a )**: [Transition Tracing] Add Support for Multiple Transitions on Root ([#24732](react/react#24732)) //<Luna Ruan>//
- **[72ebc70](react/react@72ebc703a )**: [DevTools] fix useDeferredValue to match reconciler change ([#24742](react/react#24742)) //<Mengdi Chen>//
- **[7cf9f5e](react/react@7cf9f5e03 )**: Extra space ([#24612](react/react#24612)) //<Kerim Büyükakyüz>//

Changelog:
[General][Changed] - React Native sync for revisions 229c86a...c1f5884

Reviewed By: mdvacca, GijsWeterings

Differential Revision: D38904311

fbshipit-source-id: 1e30bc420c30ec7a0c0073fc92a706afef4b3340
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@lunaruan
[Transition Tracing] Add Support for Multiple Transitions on Root (re…
0ebdb28
…act#24732)

We can think of transitions on the root as a bunch of tracing markers. Therefore, we can map each transition to a map of pending suspense boundaries. When a transition's pending suspense boundary map is empty, we know that it's complete. This PR:
* Combines the `pendingSuspenseBoundaries` and `transitions` into one `incompleteTransitions` object. This object is a map from a `transition` to a map of `pendingSuspenseBoundaries`
* Refactored code to make it so that every transition has its own `pendingSuspenseBoundaries` map rather than sharing just one.
* Moves the transition complete callback to the root. Alternatively, we can also keep a map of pendingSuspenseBoundaries to transitions on the Offscreen marker, but it's simpler to just call the transition complete callback on the root instead. We also only do this if there are transitions pending, so it shouldn't make too big of a difference
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@lunaruan
[Transition Tracing] Add Support for Multiple Transitions on Root (re…
a4751eb
…act#24732)

We can think of transitions on the root as a bunch of tracing markers. Therefore, we can map each transition to a map of pending suspense boundaries. When a transition's pending suspense boundary map is empty, we know that it's complete. This PR:
* Combines the `pendingSuspenseBoundaries` and `transitions` into one `incompleteTransitions` object. This object is a map from a `transition` to a map of `pendingSuspenseBoundaries`
* Refactored code to make it so that every transition has its own `pendingSuspenseBoundaries` map rather than sharing just one.
* Moves the transition complete callback to the root. Alternatively, we can also keep a map of pendingSuspenseBoundaries to transitions on the Offscreen marker, but it's simpler to just call the transition complete callback on the root instead. We also only do this if there are transitions pending, so it shouldn't make too big of a difference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@acdlite acdlite acdlite approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@lunaruan @sizebot @acdlite @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.