Skip to content

Support addTransitionType in startGestureTransition #32792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 1, 2025

Conversation

sebmarkbage
Copy link
Collaborator

Stacked on #32788.

Normally we track addTransitionType globally because of the async gap that can happen in Actions where we lack AsyncContext to associate it with a particular Transition. This unfortunately also means it's possible to call outside of startTransition which is something we want to warn for.

We need to be able to distinguish whether addTransitionType is for a regular Transition or a Gesture Transition though.

Since startGestureTransition is only synchronous we can track it within that execution scope and move it to a separate set. Since we know for sure which call owns it we can properly associate it with that specific provider's ScheduledGesture.

This does not yet handle calling addTransitionType inside the render phase of a gesture. That would currently still be associated with the next Transition instead.

@react-sizebot
Copy link

react-sizebot commented Mar 30, 2025

Comparing: b286430...3ff006b

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.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 515.28 kB 515.28 kB = 91.81 kB 91.81 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 619.04 kB 613.62 kB = 109.59 kB 108.49 kB
facebook-www/ReactDOM-prod.classic.js = 648.21 kB 648.21 kB = 114.54 kB 114.54 kB
facebook-www/ReactDOM-prod.modern.js = 638.49 kB 638.49 kB = 112.96 kB 112.95 kB
oss-experimental/react/cjs/react.production.js +2.73% 19.17 kB 19.69 kB +1.54% 4.87 kB 4.94 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react/cjs/react.production.js +2.73% 19.17 kB 19.69 kB +1.54% 4.87 kB 4.94 kB
oss-experimental/react/cjs/react.development.js +1.22% 47.81 kB 48.40 kB +0.60% 10.80 kB 10.86 kB
oss-experimental/react-server/cjs/react-server.production.js = 129.82 kB 129.54 kB = 22.56 kB 22.52 kB
test_utils/ReactAllWarnings.js = 64.26 kB 64.11 kB = 16.15 kB 16.09 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js = 42.59 kB 42.48 kB = 7.71 kB 7.69 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js = 42.58 kB 42.47 kB = 7.71 kB 7.69 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js = 42.56 kB 42.45 kB = 7.68 kB 7.66 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.development.js = 42.45 kB 42.34 kB = 7.69 kB 7.67 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js = 42.44 kB 42.33 kB = 7.69 kB 7.67 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js = 42.42 kB 42.31 kB = 7.66 kB 7.64 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 38.28 kB 38.18 kB = 7.11 kB 7.09 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 38.27 kB 38.17 kB = 7.10 kB 7.08 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 38.25 kB 38.15 kB = 7.07 kB 7.05 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.js = 38.15 kB 38.05 kB = 7.09 kB 7.07 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.js = 38.15 kB 38.05 kB = 7.08 kB 7.06 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.js = 38.12 kB 38.02 kB = 7.05 kB 7.03 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js = 1,126.86 kB 1,118.54 kB = 189.42 kB 188.00 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js = 1,126.71 kB 1,118.39 kB = 188.62 kB 187.21 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js = 1,110.32 kB 1,102.00 kB = 185.78 kB 184.38 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js = 674.83 kB 669.40 kB = 118.51 kB 117.31 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js = 633.45 kB 628.03 kB = 113.17 kB 112.04 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 619.04 kB 613.62 kB = 109.59 kB 108.49 kB
oss-experimental/react-art/cjs/react-art.development.js = 643.75 kB 638.03 kB = 102.84 kB 101.86 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js = 519.21 kB 514.50 kB = 82.86 kB 82.01 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js = 766.96 kB 759.78 kB = 121.13 kB 119.94 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js = 466.50 kB 461.80 kB = 74.98 kB 74.10 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js = 28.81 kB 28.29 kB = 5.66 kB 5.61 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js = 28.81 kB 28.29 kB = 5.66 kB 5.61 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js = 28.81 kB 28.29 kB = 5.66 kB 5.61 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js = 32.34 kB 31.74 kB = 5.79 kB 5.74 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js = 32.34 kB 31.74 kB = 5.79 kB 5.74 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js = 32.34 kB 31.74 kB = 5.79 kB 5.74 kB

Generated by 🚫 dangerJS against 3ff006b

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

Reviewed compared commits:

sebmarkbage/react@d52bab6...3ff006b

@sebmarkbage sebmarkbage force-pushed the gesturetransitiontypes branch from 56e1ee5 to 66c4cba Compare April 1, 2025 16:08
@sebmarkbage sebmarkbage merged commit 0b1a9e9 into facebook:main Apr 1, 2025
14 of 16 checks passed
sebmarkbage added a commit that referenced this pull request Apr 1, 2025
…#32793)

Stacked on #32792.

It's tricky to associate a specific `addTransitionType` call to a
specific `startTransition` call because we don't have `AsyncContext` in
browsers yet. However, we can keep track if there are any async
transitions running at all, and if not, warn. This should cover most
cases.

This also errors when inside a React render which might be a legit way
to associate a Transition Type to a specific render (e.g. based on props
changing) but we want to be a more conservative about allowing that yet.
If we wanted to support calling it in render, we might want to set which
Transition object is currently rendering but it's still tricky if the
render has `async function` components. So it might at least be
restricted to sync components (like Hooks).
github-actions bot pushed a commit that referenced this pull request Apr 1, 2025
Stacked on #32788.

Normally we track `addTransitionType` globally because of the async gap
that can happen in Actions where we lack AsyncContext to associate it
with a particular Transition. This unfortunately also means it's
possible to call outside of `startTransition` which is something we want
to warn for.

We need to be able to distinguish whether `addTransitionType` is for a
regular Transition or a Gesture Transition though.

Since `startGestureTransition` is only synchronous we can track it
within that execution scope and move it to a separate set. Since we know
for sure which call owns it we can properly associate it with that
specific provider's `ScheduledGesture`.

This does not yet handle calling `addTransitionType` inside the render
phase of a gesture. That would currently still be associated with the
next Transition instead.

DiffTrain build for [0b1a9e9](0b1a9e9)
github-actions bot pushed a commit that referenced this pull request Apr 1, 2025
…#32793)

Stacked on #32792.

It's tricky to associate a specific `addTransitionType` call to a
specific `startTransition` call because we don't have `AsyncContext` in
browsers yet. However, we can keep track if there are any async
transitions running at all, and if not, warn. This should cover most
cases.

This also errors when inside a React render which might be a legit way
to associate a Transition Type to a specific render (e.g. based on props
changing) but we want to be a more conservative about allowing that yet.
If we wanted to support calling it in render, we might want to set which
Transition object is currently rendering but it's still tricky if the
render has `async function` components. So it might at least be
restricted to sync components (like Hooks).

DiffTrain build for [deca965](deca965)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants