Skip to content
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

useTransition improvements #17418

Closed
wants to merge 5 commits into from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Nov 21, 2019

  • When multiple transitions update the same queue, only the most recent
    one should be considered pending. Example: If I switch tabs multiple times, only the last tab I click should display a pending state (e.g. an inline spinner).
  • When multiple transitions update the same queue, only the most recent one should be allowed to finish. Do not display intermediate states. Example: if you click on multiple tabs in quick succession, we should not switch to any tab that isn't the last one you clicked.

Here's the CodeSandbox I'm using to test the changes: https://codesandbox.io/s/elastic-hawking-69381. It's a tab switcher. Switch tabs and pay attention to the pending spinners.

@acdlite
Copy link
Collaborator Author

acdlite commented Nov 21, 2019

@CompuIves Any idea why CodeSandbox CI isn't running on this PR?

@sizebot
Copy link

sizebot commented Nov 21, 2019

Details of bundled changes.

Comparing: f2fd484...734285d

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +1.7% +2.0% 123.67 KB 125.77 KB 38.77 KB 39.54 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 137.89 KB 137.89 KB 36.65 KB 36.65 KB UMD_DEV
react-dom-test-utils.development.js 0.0% 0.0% 54.65 KB 54.66 KB 15.36 KB 15.36 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.88 KB 3.88 KB 1.55 KB 1.55 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 11.18 KB 11.18 KB 4.15 KB 4.15 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.21 KB 1.21 KB 710 B 712 B UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 52.93 KB 52.93 KB 15.04 KB 15.04 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.71 KB 3.71 KB 1.5 KB 1.5 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.95 KB 10.95 KB 4.09 KB 4.09 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.05 KB 1.05 KB 641 B 643 B NODE_PROD
react-dom.development.js +1.3% +1.0% 956.28 KB 969.1 KB 214.9 KB 216.97 KB UMD_DEV
react-dom.production.min.js 🔺+1.7% 🔺+2.1% 119.69 KB 121.76 KB 38.37 KB 39.19 KB UMD_PROD
react-dom.profiling.min.js +1.7% +1.9% 123.42 KB 125.5 KB 39.57 KB 40.3 KB UMD_PROFILING
react-dom.development.js +1.3% +1.0% 950.34 KB 963.16 KB 213.19 KB 215.27 KB NODE_DEV
react-dom-server.node.development.js 0.0% 0.0% 134.93 KB 134.93 KB 35.85 KB 35.86 KB NODE_DEV
react-dom.production.min.js 🔺+1.7% 🔺+2.1% 119.79 KB 121.88 KB 37.64 KB 38.42 KB NODE_PROD
ReactTestUtils-dev.js +0.1% +0.1% 52.37 KB 52.44 KB 14.28 KB 14.29 KB FB_WWW_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.8 KB 20.8 KB 7.63 KB 7.63 KB NODE_PROD
react-dom-server.browser.development.js 0.0% 0.0% 133.82 KB 133.82 KB 35.62 KB 35.62 KB NODE_DEV
ReactDOM-dev.js +1.3% +1.3% 978 KB 991.08 KB 216.12 KB 218.83 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 20.39 KB 20.39 KB 7.47 KB 7.47 KB NODE_PROD
ReactDOM-prod.js 🔺+2.1% 🔺+1.7% 394.21 KB 402.3 KB 72.06 KB 73.26 KB FB_WWW_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.91 KB 60.91 KB 16.07 KB 16.07 KB UMD_DEV
ReactDOM-profiling.js +2.0% +1.6% 405.5 KB 413.57 KB 74.22 KB 75.41 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.23 KB 10.23 KB 3.47 KB 3.48 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.61 KB 60.61 KB 15.99 KB 16 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 4.42 KB 4.42 KB 1.65 KB 1.65 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 9.97 KB 9.97 KB 3.37 KB 3.38 KB NODE_PROD
ReactDOMServer-dev.js 0.0% +0.1% 139.4 KB 139.47 KB 35.43 KB 35.45 KB FB_WWW_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.3% 1.21 KB 1.21 KB 697 B 699 B NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +2.1% +1.6% 622.44 KB 635.26 KB 131.33 KB 133.41 KB UMD_DEV
react-test-renderer.production.min.js 🔺+2.9% 🔺+3.4% 71.99 KB 74.06 KB 21.93 KB 22.68 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% -0.0% 37.83 KB 37.83 KB 9.81 KB 9.81 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.66 KB 11.66 KB 3.6 KB 3.6 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% 0.0% 32.37 KB 32.37 KB 8.5 KB 8.5 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.79 KB 11.79 KB 3.71 KB 3.71 KB NODE_PROD
react-test-renderer.development.js +2.1% +1.6% 617.71 KB 630.53 KB 130.14 KB 132.23 KB NODE_DEV
react-test-renderer.production.min.js 🔺+2.9% 🔺+3.5% 71.69 KB 73.77 KB 21.55 KB 22.32 KB NODE_PROD
ReactTestRenderer-dev.js +2.1% +1.6% 633.53 KB 646.58 KB 130.98 KB 133.08 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +1.7% +1.3% 750.51 KB 763.56 KB 157.79 KB 159.88 KB RN_OSS_DEV
ReactFabric-dev.js +1.8% +1.3% 741.13 KB 754.18 KB 155.58 KB 157.65 KB RN_OSS_DEV
ReactNativeRenderer-dev.js +1.7% +1.3% 750.69 KB 763.74 KB 157.89 KB 159.97 KB RN_FB_DEV
ReactFabric-prod.js 🔺+3.2% 🔺+2.3% 267.1 KB 275.58 KB 45.83 KB 46.86 KB RN_OSS_PROD
ReactNativeRenderer-prod.js 🔺+3.1% 🔺+2.2% 275.07 KB 283.54 KB 47.16 KB 48.18 KB RN_FB_PROD
ReactFabric-profiling.js +3.0% +2.1% 278.23 KB 286.68 KB 47.96 KB 48.97 KB RN_OSS_PROFILING
ReactNativeRenderer-profiling.js +3.0% +2.1% 286.23 KB 294.69 KB 49.3 KB 50.32 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js 🔺+3.1% 🔺+2.2% 274.68 KB 283.15 KB 47.09 KB 48.11 KB RN_OSS_PROD
ReactFabric-dev.js +1.8% +1.3% 741.31 KB 754.36 KB 155.67 KB 157.74 KB RN_FB_DEV
ReactNativeRenderer-profiling.js +3.0% +2.1% 285.85 KB 294.3 KB 49.23 KB 50.25 KB RN_OSS_PROFILING
ReactFabric-prod.js 🔺+3.2% 🔺+2.2% 267.45 KB 275.93 KB 45.9 KB 46.93 KB RN_FB_PROD
ReactFabric-profiling.js +3.0% +2.1% 278.58 KB 287.03 KB 48.02 KB 49.03 KB RN_FB_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +2.1% +1.6% 621.94 KB 635.02 KB 128.44 KB 130.53 KB FB_WWW_DEV
ReactART-prod.js 🔺+3.7% 🔺+2.7% 236.72 KB 245.42 KB 39.91 KB 40.98 KB FB_WWW_PROD
react-art.development.js +1.9% +1.4% 677.57 KB 690.39 KB 145.77 KB 147.85 KB UMD_DEV
react-art.production.min.js 🔺+1.9% 🔺+2.3% 107.32 KB 109.39 KB 32.52 KB 33.26 KB UMD_PROD
react-art.development.js +2.1% +1.6% 608.25 KB 621.07 KB 128.35 KB 130.42 KB NODE_DEV
react-art.production.min.js 🔺+2.9% 🔺+3.3% 72.29 KB 74.37 KB 21.68 KB 22.4 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js +2.1% +1.7% 606.54 KB 619.36 KB 126.36 KB 128.45 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% 0.0% 19.42 KB 19.42 KB 6.37 KB 6.38 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+2.9% 🔺+3.3% 72.59 KB 74.68 KB 21.31 KB 22.01 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.86 KB 2.86 KB 1.24 KB 1.24 KB NODE_PROD
react-reconciler.development.js +2.1% +1.6% 609.25 KB 622.07 KB 127.52 KB 129.6 KB NODE_DEV
react-reconciler.production.min.js 🔺+2.8% 🔺+3.3% 75.29 KB 77.38 KB 21.96 KB 22.68 KB NODE_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against 734285d

@sizebot
Copy link

sizebot commented Nov 21, 2019

Details of bundled changes.

Comparing: f2fd484...734285d

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.production.min.js 🔺+1.9% 🔺+2.3% 104.82 KB 106.86 KB 31.83 KB 32.55 KB UMD_PROD
react-art.development.js +1.9% +1.4% 677.54 KB 690.37 KB 145.76 KB 147.84 KB UMD_DEV
react-art.development.js +2.1% +1.6% 608.22 KB 621.05 KB 128.34 KB 130.42 KB NODE_DEV
react-art.production.min.js 🔺+2.9% 🔺+3.3% 69.83 KB 71.88 KB 21 KB 21.7 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.production.min.js 🔺+2.8% 🔺+3.3% 72.58 KB 74.64 KB 21.3 KB 22 KB NODE_PROD
react-reconciler.development.js +2.1% +1.6% 609.24 KB 622.06 KB 127.52 KB 129.6 KB NODE_DEV
react-reconciler.production.min.js 🔺+2.8% 🔺+3.3% 72.57 KB 74.63 KB 21.29 KB 21.99 KB NODE_PROD
react-reconciler-reflection.development.js 0.0% 0.0% 19.41 KB 19.41 KB 6.37 KB 6.37 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.85 KB 2.85 KB 1.24 KB 1.24 KB NODE_PROD
react-reconciler-persistent.development.js +2.1% +1.7% 606.53 KB 619.35 KB 126.35 KB 128.45 KB NODE_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js +1.8% +1.3% 741.12 KB 754.17 KB 155.58 KB 157.64 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+3.1% 🔺+2.2% 267.09 KB 275.43 KB 45.82 KB 46.83 KB RN_OSS_PROD
ReactNativeRenderer-dev.js +1.7% +1.3% 750.5 KB 763.55 KB 157.79 KB 159.87 KB RN_OSS_DEV
ReactFabric-profiling.js +3.0% +2.0% 278.22 KB 286.53 KB 47.95 KB 48.93 KB RN_OSS_PROFILING
ReactNativeRenderer-prod.js 🔺+3.0% 🔺+2.1% 274.66 KB 283 KB 47.08 KB 48.07 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +2.9% +2.0% 285.84 KB 294.15 KB 49.22 KB 50.22 KB RN_OSS_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.production.min.js 0.0% 0.0% 19.94 KB 19.94 KB 7.39 KB 7.4 KB NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 52.91 KB 52.92 KB 15.03 KB 15.03 KB NODE_DEV
react-dom.production.min.js 🔺+1.8% 🔺+2.2% 115.85 KB 117.9 KB 37.25 KB 38.06 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.59 KB 60.59 KB 15.99 KB 15.99 KB NODE_DEV
react-dom.profiling.min.js +1.7% +2.1% 119.47 KB 121.53 KB 38.39 KB 39.19 KB UMD_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.96 KB 9.96 KB 3.36 KB 3.37 KB NODE_PROD
react-dom.development.js +1.3% +1.0% 950.32 KB 963.14 KB 213.17 KB 215.24 KB NODE_DEV
react-dom.production.min.js 🔺+1.8% 🔺+2.0% 115.92 KB 117.98 KB 36.59 KB 37.34 KB NODE_PROD
react-dom.profiling.min.js +1.7% +2.0% 119.69 KB 121.75 KB 37.71 KB 38.47 KB NODE_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 3.87 KB 3.87 KB 1.54 KB 1.54 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.2 KB 1.2 KB 702 B 704 B UMD_PROD
react-dom-server.browser.development.js 0.0% 0.0% 137.86 KB 137.86 KB 36.65 KB 36.65 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 20.01 KB 20.01 KB 7.41 KB 7.41 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 3.7 KB 3.7 KB 1.49 KB 1.5 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 54.64 KB 54.64 KB 15.35 KB 15.35 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.04 KB 1.04 KB 633 B 635 B NODE_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 11.17 KB 11.17 KB 4.14 KB 4.14 KB UMD_PROD
react-dom-server.browser.development.js 0.0% 0.0% 133.79 KB 133.8 KB 35.62 KB 35.62 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.94 KB 10.94 KB 4.08 KB 4.09 KB NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.2% 4.4 KB 4.4 KB 1.64 KB 1.64 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.89 KB 60.89 KB 16.06 KB 16.07 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.4% 1.2 KB 1.2 KB 688 B 691 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 10.22 KB 10.22 KB 3.47 KB 3.47 KB UMD_PROD
react-dom-server.node.development.js 0.0% 0.0% 134.9 KB 134.91 KB 35.85 KB 35.85 KB NODE_DEV
react-dom.development.js +1.3% +1.0% 956.25 KB 969.08 KB 214.88 KB 216.95 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.34 KB 20.34 KB 7.55 KB 7.55 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.development.js 0.0% -0.0% 37.81 KB 37.81 KB 9.8 KB 9.8 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.64 KB 11.64 KB 3.59 KB 3.59 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% 0.0% 32.35 KB 32.35 KB 8.49 KB 8.49 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.78 KB 11.78 KB 3.7 KB 3.7 KB NODE_PROD
react-test-renderer.development.js +2.1% +1.6% 622.42 KB 635.24 KB 131.32 KB 133.39 KB UMD_DEV
react-test-renderer.production.min.js 🔺+2.8% 🔺+3.3% 71.96 KB 74.01 KB 21.91 KB 22.64 KB UMD_PROD
react-test-renderer.development.js +2.1% +1.6% 617.68 KB 630.51 KB 130.13 KB 132.22 KB NODE_DEV
react-test-renderer.production.min.js 🔺+2.9% 🔺+3.5% 71.67 KB 73.72 KB 21.54 KB 22.28 KB NODE_PROD

ReactDOM: size: 🔺+1.8%, gzip: 🔺+2.2%

Size changes (stable)

Generated by 🚫 dangerJS against 734285d

@acdlite acdlite force-pushed the transition-improvements branch 5 times, most recently from 2c169a5 to 98cebf8 Compare November 21, 2019 21:19
@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 21, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 734285d:

Sandbox Source
withered-cookies-io19b Configuration

@acdlite acdlite force-pushed the transition-improvements branch 2 times, most recently from cf22a72 to e7fd438 Compare November 26, 2019 21:50
@acdlite acdlite force-pushed the transition-improvements branch 3 times, most recently from 19a5e82 to 5c0fd23 Compare December 15, 2019 21:40
@acdlite acdlite force-pushed the transition-improvements branch 3 times, most recently from aa759fb to da8c9f2 Compare December 19, 2019 23:11
@acdlite acdlite mentioned this pull request Dec 19, 2019
1 task
@necolas necolas added the React Core Team Opened by a member of the React Core Team label Jan 8, 2020
@acdlite acdlite force-pushed the transition-improvements branch 2 times, most recently from 2400d7b to 2510ef2 Compare January 9, 2020 19:23
@acdlite acdlite force-pushed the transition-improvements branch 3 times, most recently from 6a30245 to 0294458 Compare January 17, 2020 21:02
The `isPending` state managed by the `useTransition` queue can be
modeled using the same queue as useState/useReducer; that's how it's
implemented today. However, since there's only ever a single pending
transition per `useTransition` hook, and the most recent one always
wins, we don't really need to maintain an entire queue structure.

This replaces the internal `useState` queue with a specialized
implementation. It tracks the most recent transition expiration time
on shared instance object, and the last processed expiration time on
each hook copy. When the processed expiration time catches up to the
pending one, we know that the transition is no longer pending. At a
high level, this is also how the `useState` queue works, but without
the overhead of an actual queue.

The implementation is also inspired by Suspense boundaries, which also
have an internal state for whether the boundary is displaying a
fallback, but does not use an actual queue to manage that state.
When multiple transitions update the same queue, only the most recent
one should be considered pending.

Example: If I switch tabs multiple times, only the last tab I click
should display a pending state (e.g. an inline spinner).
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. Do not display intermediate states.

For example, if you click on multiple tabs in quick succession, we
should not switch to any tab that isn't the last one you clicked.
@acdlite acdlite force-pushed the transition-improvements branch 4 times, most recently from 6f18dfd to b11cff3 Compare January 21, 2020 20:53
We currently use the expiration time to represent the timeout of a
transition. Since we intend to stop treating work priority as a
timeline, we can no longer use this trick.

In this commit, I've changed it to store the event time on the update
object instead. Long term, we will store event time on the root as a map
of transition -> event time. I'm only storing it on the update object
as a temporary workaround to unblock the rest of the changes.
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. Do not display intermediate states.

For example, if you click on multiple tabs in quick succession, we
should not switch to any tab that isn't the last one you clicked.
@acdlite
Copy link
Collaborator Author

acdlite commented Jan 24, 2020

Closed in favor of #17908

@acdlite acdlite closed this Jan 24, 2020
acdlite added a commit to acdlite/react that referenced this pull request Jan 27, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See facebook#17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.

To avoid too many combinations of behavior, I'm reusing the feature
flag I added in my last PR (enableTransitionEntanglement). I'll wait
until the existing behavior has rolled out before landing this one.
acdlite added a commit to acdlite/react that referenced this pull request Jan 27, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See facebook#17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.
acdlite added a commit to acdlite/react that referenced this pull request Jan 27, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See facebook#17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.
acdlite added a commit to acdlite/react that referenced this pull request Jan 27, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See facebook#17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.
acdlite added a commit that referenced this pull request Jan 27, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See #17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
When multiple transitions update the same queue, only the most recent
one should be allowed to finish. We shouldn't show intermediate states.

See facebook#17418 for background on why this is important.

The way this currently works is that we always assign the same lane to
all transitions. It's impossible for one transition to finish without
also finishing all the others.

The downside of the current approach is that it's too aggressive. Not
all transitions are related to each other, so one should not block
the other.

The new approach is to only entangle transitions if they update one or
more of the same state hooks (or class components), because this
indicates that they are related. If they are unrelated, then they can
finish in any order, as long as they have different lanes.

However, this commit does not change anything about how the lanes are
assigned. All it does is add the mechanism to entangle per queue. So it
doesn't actually change any behavior, yet. But it's a requirement for my
next step, which is to assign different lanes to consecutive transitions
until we run out and cycle back to the beginning.
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