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

Proposed new Suspense layout effect semantics #21079

Merged
merged 4 commits into from Apr 6, 2021

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Mar 24, 2021

This PR contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)

Breakdown

This PR is split into a few commits:

  1. First, a new feature flag (enableSuspenseLayoutEffectSemantics) enabled for variant tests only (__VARIANT__) and toggleable by a GK in Facebook builds.
  2. A new test suite (ReactSuspenseEffectsSemantics-test.js) covering the changes to layout effects and refs semantics.
  3. The actual reconciler changes to layout effects and refs semantics. (This is the commit to review.)
  4. Gating a fuzz test (ReactSuspenseFuzz-test.internal.js) that fails b'c of the changed semantics. (The failure is expected. A comment was left explaining why.)

Checklist

  • Audit feature flags to make sure DCE works (including for nested if/else statements). OSS build contains no references to RefStatic/LayoutStatic flags, enableSuspenseLayoutEffectSemantics feature flag, or offscreenSubtree* stack variables.
  • Final audit for naming and inline comments.
  • Fix failing ReactLazy-test.internal.js test.
  • Gated failing ReactSuspenseFuzz-test.internal.js test with an explanatory comment.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 24, 2021
@sizebot
Copy link

sizebot commented Mar 24, 2021

Comparing: b48b38a...8c191e8

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 = 122.62 kB 122.63 kB = 39.34 kB 39.34 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 129.19 kB 129.19 kB +0.01% 41.42 kB 41.43 kB
facebook-www/ReactDOM-prod.classic.js +1.62% 405.80 kB 412.38 kB +1.11% 75.37 kB 76.21 kB
facebook-www/ReactDOM-prod.modern.js +1.62% 394.06 kB 400.44 kB +1.11% 73.51 kB 74.33 kB
facebook-www/ReactDOMForked-prod.classic.js +1.62% 405.80 kB 412.38 kB +1.11% 75.37 kB 76.21 kB
facebook-www/ReactART-prod.classic.js +2.32% 261.32 kB 267.38 kB +1.81% 46.56 kB 47.41 kB
facebook-www/ReactART-prod.modern.js +2.31% 253.96 kB 259.81 kB +1.81% 45.32 kB 46.14 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactART-prod.classic.js +2.32% 261.32 kB 267.38 kB +1.81% 46.56 kB 47.41 kB
facebook-www/ReactART-prod.modern.js +2.31% 253.96 kB 259.81 kB +1.81% 45.32 kB 46.14 kB
facebook-www/ReactDOM-profiling.classic.js +1.68% 427.63 kB 434.81 kB +1.26% 78.97 kB 79.96 kB
facebook-www/ReactDOMForked-profiling.classic.js +1.68% 427.63 kB 434.81 kB +1.26% 78.97 kB 79.97 kB
facebook-www/ReactDOM-profiling.modern.js +1.68% 415.86 kB 422.83 kB +1.26% 77.15 kB 78.12 kB
facebook-www/ReactDOMForked-profiling.modern.js +1.68% 415.86 kB 422.83 kB +1.26% 77.15 kB 78.12 kB
facebook-www/ReactDOM-prod.classic.js +1.62% 405.80 kB 412.38 kB +1.11% 75.37 kB 76.21 kB
facebook-www/ReactDOMForked-prod.classic.js +1.62% 405.80 kB 412.38 kB +1.11% 75.37 kB 76.21 kB
facebook-www/ReactDOM-prod.modern.js +1.62% 394.06 kB 400.44 kB +1.11% 73.51 kB 74.33 kB
facebook-www/ReactDOMForked-prod.modern.js +1.62% 394.06 kB 400.44 kB +1.11% 73.51 kB 74.33 kB
facebook-www/ReactART-dev.modern.js +1.26% 691.48 kB 700.17 kB +1.06% 147.52 kB 149.10 kB
facebook-www/ReactART-dev.classic.js +1.24% 701.77 kB 710.46 kB +1.05% 149.58 kB 151.15 kB
facebook-www/ReactIs-dev.classic.js +1.03% 9.82 kB 9.92 kB +0.78% 2.68 kB 2.70 kB
facebook-www/ReactIs-dev.modern.js +1.00% 10.09 kB 10.19 kB +0.73% 2.72 kB 2.74 kB
facebook-www/SchedulerTracing-dev.modern.js +0.91% 11.11 kB 11.21 kB +0.98% 2.45 kB 2.48 kB
facebook-www/SchedulerTracing-dev.classic.js +0.91% 11.11 kB 11.21 kB +0.98% 2.45 kB 2.48 kB
facebook-www/ReactDOMForked-dev.modern.js +0.84% 1,029.91 kB 1,038.59 kB +0.69% 228.95 kB 230.52 kB
facebook-www/ReactDOM-dev.modern.js +0.84% 1,029.91 kB 1,038.59 kB +0.69% 228.95 kB 230.52 kB
facebook-www/ReactDOMForked-dev.classic.js +0.82% 1,056.15 kB 1,064.84 kB +0.68% 234.38 kB 235.98 kB
facebook-www/ReactDOM-dev.classic.js +0.82% 1,056.15 kB 1,064.84 kB +0.69% 234.38 kB 235.98 kB
facebook-www/JSXDEVRuntime-dev.modern.js +0.24% 41.87 kB 41.97 kB +0.20% 11.72 kB 11.75 kB
facebook-www/JSXDEVRuntime-dev.classic.js +0.24% 41.87 kB 41.97 kB +0.20% 11.72 kB 11.75 kB

Generated by 🚫 dangerJS against 8c191e8

@Andarist
Copy link
Contributor

This only touches layout effects (so kinda a good thing - considering they are less common in applications, so the impact is minimized). From the comments/tweets in the past I was under the impression that such a change is being discussed for all effects - was it always specifically about layout effects and I've just assumed the other intention? Or maybe passive effects got excluded from that in the process of experimenting with it? Is there any plan to experiment with similar semantics for passive effects?

Are React-managed refs those that are passed to the ref prop? Or is there anything else to it? Would it make sense to add a dev-only warning about non-React write attempts to React-managed refs? From what I see there is no such warning. Doing something like this was always not the best idea and I haven't actually seen any code doing it but maybe worth adding something like this nevertheless.

@bvaughn
Copy link
Contributor Author

bvaughn commented Mar 24, 2021

This only touches layout effects (so kinda a good thing - considering they are less common in applications, so the impact is minimized). From the comments/tweets in the past I was under the impression that such a change is being discussed for all effects - was it always specifically about layout effects and I've just assumed the other intention? Or maybe passive effects got excluded from that in the process of experimenting with it? Is there any plan to experiment with similar semantics for passive effects?

@Andarist: See this comment in the PR:

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

We plan to offer a way to cleanup passive effects as well. This is just an incremental step.

Are React-managed refs those that are passed to the ref prop?

React-managed refs are when a ref attribute is set on a host component (e.g. <div>), a class component, or a function component that uses the useImperativeHandle API.

@Andarist
Copy link
Contributor

We plan to offer a way to cleanup passive effects as well. This is just an incremental step.

Will this be controllable by the user for passive effects?

React-managed refs are when a ref attribute is set on a host component (e.g.

), a class component, or a function component that uses the useImperativeHandle API.

Gotcha, that's what I thought - thanks for clarifying 👍

@bvaughn
Copy link
Contributor Author

bvaughn commented Mar 24, 2021

@Andarist We'll provide more detail about this soon 😄 ("More to follow.")

@Andarist
Copy link
Contributor

Ok, I'll practice being patient. It ain't easy though! 😅

Comment on lines 481 to 483
current !== null &&
(current.flags & PassiveStaticEffect) !==
(workInProgress.flags & PassiveStaticEffect)
(current.flags & StaticMaskEffect) !==
(workInProgress.flags & StaticMaskEffect)
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@acdlite mentioned a concern that we might not be resetting static flags correctly. This DEV check has been expanded to also cover the static layout and ref flags.

Comment on lines +2409 to +2375
if (
enableSuspenseLayoutEffectSemantics &&
isModernRoot &&
offscreenSubtreeWasHidden &&
!offscreenSubtreeIsHidden
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've verified in the built bundle that DCE works to correctly strip these conditional branches when enableSuspenseLayoutEffectSemantics is false.

@bvaughn
Copy link
Contributor Author

bvaughn commented Mar 29, 2021

The failing ReactLazy-test.internal.js revealed a new scenario I need to add a case to ReactSuspenseEffectsSemantics for.

  • Add new test

@bvaughn bvaughn force-pushed the suspense-layout-effects branch 2 times, most recently from 58a403b to d9be7b5 Compare March 30, 2021 02:15
@bvaughn
Copy link
Contributor Author

bvaughn commented Mar 30, 2021

I think everything passes now except the Suspense fuzz test, which caught a problem that I need to dig into:

<React.Suspense
  fallback="Loading..."
> 
  <React.Suspense>
    <React.Suspense>
      <Text
        initialDelay={9683}
        text="E"
        updates={[]}
      />
    </React.Suspense>
    <Text
      initialDelay={4053}
      text="C"
      updates={
        [
          {
            "beginAfter": 1566,
            "suspendFor": 4142,
          },
          {
            "beginAfter": 9572,
            "suspendFor": 4832,
          },
        ]
      }
    />
  </React.Suspense>
</React.Suspense>
);

The variant yields "E:0C:1" when the test expects "E:0C:2". I'll dig in tomorrow.

Looking closer at this, the difference is related to this semantic change. The legacy root output and effects match (because the new semantics only apply to modern roots) but the modern root varies: when a certain subtree is hidden (because it suspends in an update), its layout effects are destroyed and not recreated. In the legacy branch, layout effects are created an additional time.

Not yet sure if this indicates a problem with my implementation or just an expected observable difference.

@bvaughn bvaughn force-pushed the suspense-layout-effects branch 2 times, most recently from 786c2c9 to 1ad6bb7 Compare March 30, 2021 02:47
@bvaughn
Copy link
Contributor Author

bvaughn commented Mar 30, 2021

Digging into the above failing test case further. The behavior of both control group and sync legacy render match. (New semantics aren't enabled for legacy roots.) In both groups we only create layout effects once.

In the final batch of ReactNoop.createRoot().render() work though, the behavior differs. When the subtree suspends in an update, and gets hidden, the new branch destroys the layout effect but the old branch doesn't. This means that the second, larger beginAfter timeout is able to fire before the end of the test which increments the state an additional time.

@bvaughn bvaughn marked this pull request as ready for review March 30, 2021 15:03
@bvaughn bvaughn changed the title [draft] Proposed new Suspense layout effect semantics Proposed new Suspense layout effect semantics Mar 30, 2021
@bvaughn bvaughn force-pushed the suspense-layout-effects branch 5 times, most recently from ec2d1ff to 7e40b76 Compare March 31, 2021 02:27
Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

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

Looks great! Pair reviewed out-of-band and discussed follow ups.

I think the main ones we'll want to address before rolling out is 1) removing the StaticFlag check during traversal, until we fix the outstanding bug that's causing static flags to be cleared incorrectly, and 2) using the JS stack to track whether we're inside a toggled tree, instead of an array-based stack.

Since this is behind a flag, and the overall algorithm is good, we can do those in separate PRs.

So excited to get this merged!

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 6, 2021

Excellent. Thanks!

@bvaughn bvaughn merged commit 7c1ba2b into facebook:master Apr 6, 2021
@bvaughn bvaughn deleted the suspense-layout-effects branch April 6, 2021 13:21
@gaearon gaearon mentioned this pull request Apr 7, 2021
63 tasks
acdlite pushed a commit to acdlite/react that referenced this pull request Apr 11, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
acdlite pushed a commit to acdlite/react that referenced this pull request Apr 13, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
acdlite pushed a commit to acdlite/react that referenced this pull request Apr 16, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
acdlite pushed a commit to acdlite/react that referenced this pull request Apr 16, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
acdlite pushed a commit to acdlite/react that referenced this pull request Apr 19, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Apr 20, 2021
Summary:
This sync includes the following changes:
- **[f7cdc8936](facebook/react@f7cdc8936 )**: Also turn off enableSyncDefaultUpdates in RN test renderer ([#21293](facebook/react#21293)) //<Ricky>//
- **[4c9eb2af1](facebook/react@4c9eb2af1 )**: Add dynamic flags to React Native ([#21291](facebook/react#21291)) //<Ricky>//
- **[9eddfbf5a](facebook/react@9eddfbf5a )**: [Fizz] Two More Fixes ([#21288](facebook/react#21288)) //<Sebastian Markbåge>//
- **[11b07597e](facebook/react@11b07597e )**: Fix classes ([#21283](facebook/react#21283)) //<Sebastian Markbåge>//
- **[96d00b9bb](facebook/react@96d00b9bb )**: [Fizz] Random Fixes ([#21277](facebook/react#21277)) //<Sebastian Markbåge>//
- **[81ef53953](facebook/react@81ef53953 )**: Always insert a dummy node with an ID into fallbacks ([#21272](facebook/react#21272)) //<Sebastian Markbåge>//
- **[a4a940d7a](facebook/react@a4a940d7a )**: [Fizz] Add unsupported Portal/Scope components ([#21261](facebook/react#21261)) //<Sebastian Markbåge>//
- **[f4d7a0f1e](facebook/react@f4d7a0f1e )**: Implement useOpaqueIdentifier ([#21260](facebook/react#21260)) //<Sebastian Markbåge>//
- **[dde875dfb](facebook/react@dde875dfb )**: [Fizz] Implement Hooks ([#21257](facebook/react#21257)) //<Sebastian Markbåge>//
- **[a597c2f5d](facebook/react@a597c2f5d )**: [Fizz] Fix reentrancy bug ([#21270](facebook/react#21270)) //<Sebastian Markbåge>//
- **[15e779d92](facebook/react@15e779d92 )**: Reconciler should inject its own version into DevTools hook ([#21268](facebook/react#21268)) //<Brian Vaughn>//
- **[4f76a28c9](facebook/react@4f76a28c9 )**: [Fizz] Implement New Context ([#21255](facebook/react#21255)) //<Sebastian Markbåge>//
- **[82ef450e0](facebook/react@82ef450e0 )**: remove obsolete SharedArrayBuffer ESLint config ([#21259](facebook/react#21259)) //<Henry Q. Dineen>//
- **[dbadfa2c3](facebook/react@dbadfa2c3 )**: [Fizz] Classes Follow Up ([#21253](facebook/react#21253)) //<Sebastian Markbåge>//
- **[686b635b7](facebook/react@686b635b7 )**: Prevent reading canonical property of null ([#21242](facebook/react#21242)) //<Joshua Gross>//
- **[bb88ce95a](facebook/react@bb88ce95a )**: Bugfix: Don't rely on `finishedLanes` for passive effects ([#21233](facebook/react#21233)) //<Andrew Clark>//
- **[343710c92](facebook/react@343710c92 )**: [Fizz] Fragments and Iterable support ([#21228](facebook/react#21228)) //<Sebastian Markbåge>//
- **[933880b45](facebook/react@933880b45 )**: Make time-slicing opt-in ([#21072](facebook/react#21072)) //<Ricky>//
- **[b0407b55f](facebook/react@b0407b55f )**: Support more empty types ([#21225](facebook/react#21225)) //<Sebastian Markbåge>//
- **[39713716a](facebook/react@39713716a )**: Merge isObject branches ([#21226](facebook/react#21226)) //<Sebastian Markbåge>//
- **[8a4a59c72](facebook/react@8a4a59c72 )**: Remove textarea special case from child fiber ([#21222](facebook/react#21222)) //<Sebastian Markbåge>//
- **[dc108b0f5](facebook/react@dc108b0f5 )**: Track which fibers scheduled the current render work ([#15658](facebook/react#15658)) //<Brian Vaughn>//
- **[6ea749170](facebook/react@6ea749170 )**: Fix typo in comment ([#21214](facebook/react#21214)) //<inokawa>//
- **[b38ac13f9](facebook/react@b38ac13f9 )**: DevTools: Add post-commit hook ([#21183](facebook/react#21183)) //<Brian Vaughn>//
- **[b943aeba8](facebook/react@b943aeba8 )**: Fix: Passive effect updates are never sync ([#21215](facebook/react#21215)) //<Andrew Clark>//
- **[d389c54d1](facebook/react@d389c54d1 )**: Offscreen: Use JS stack to track hidden/unhidden subtree state ([#21211](facebook/react#21211)) //<Brian Vaughn>//
- **[c486dc1a4](facebook/react@c486dc1a4 )**: Remove unnecessary processUpdateQueue ([#21199](facebook/react#21199)) //<Sebastian Markbåge>//
- **[cf45a623a](facebook/react@cf45a623a )**: [Fizz] Implement Classes ([#21200](facebook/react#21200)) //<Sebastian Markbåge>//
- **[75c616554](facebook/react@75c616554 )**: Include actual type of `Profiler#id` on type mismatch ([#20306](facebook/react#20306)) //<Sebastian Silbermann>//
- **[1214b302e](facebook/react@1214b302e )**: test: Fix "couldn't locate all inline snapshots" ([#21205](facebook/react#21205)) //<Sebastian Silbermann>//
- **[1a02d2792](facebook/react@1a02d2792 )**: style: delete unused isHost check ([#21203](facebook/react#21203)) //<wangao>//
- **[782f689ca](facebook/react@782f689ca )**: Don't double invoke getDerivedStateFromProps for module pattern ([#21193](facebook/react#21193)) //<Sebastian Markbåge>//
- **[e90c76a65](facebook/react@e90c76a65 )**: Revert "Offscreen: Use JS stack to track hidden/unhidden subtree state" ([#21194](facebook/react#21194)) //<Brian Vaughn>//
- **[1f8583de8](facebook/react@1f8583de8 )**: Offscreen: Use JS stack to track hidden/unhidden subtree state ([#21192](facebook/react#21192)) //<Brian Vaughn>//
- **[ad6e6ec7b](facebook/react@ad6e6ec7b )**: [Fizz] Prepare Recursive Loop for More Types ([#21186](facebook/react#21186)) //<Sebastian Markbåge>//
- **[172e89b4b](facebook/react@172e89b4b )**: Reland Remove redundant initial of isArray ([#21188](facebook/react#21188)) //<Sebastian Markbåge>//
- **[7c1ba2b57](facebook/react@7c1ba2b57 )**: Proposed new Suspense layout effect semantics ([#21079](facebook/react#21079)) //<Brian Vaughn>//
- **[316aa3686](facebook/react@316aa3686 )**: [Scheduler] Fix de-opt caused by out-of-bounds access ([#21147](facebook/react#21147)) //<Andrey Marchenko>//
- **[b4f119cdf](facebook/react@b4f119cdf )**: Revert "Remove redundant initial of isArray ([#21163](facebook/react#21163))" //<Sebastian Markbage>//
- **[c03197063](facebook/react@c03197063 )**: Revert "apply prettier ([#21165](facebook/react#21165))" //<Sebastian Markbage>//
- **[94fd1214d](facebook/react@94fd1214d )**: apply prettier ([#21165](facebook/react#21165)) //<Behnam Mohammadi>//
- **[b130a0f5c](facebook/react@b130a0f5c )**: Remove redundant initial of isArray ([#21163](facebook/react#21163)) //<Behnam Mohammadi>//
- **[2c9fef32d](facebook/react@2c9fef32d )**: Remove redundant initial of hasOwnProperty ([#21134](facebook/react#21134)) //<Behnam Mohammadi>//
- **[1cf9978d8](facebook/react@1cf9978d8 )**: Don't pass internals to callbacks ([#21161](facebook/react#21161)) //<Sebastian Markbåge>//
- **[b9e4c10e9](facebook/react@b9e4c10e9 )**: [Fizz] Implement all the DOM attributes and special cases ([#21153](facebook/react#21153)) //<Sebastian Markbåge>//
- **[f8ef4ff57](facebook/react@f8ef4ff57 )**: Flush discrete passive effects before paint ([#21150](facebook/react#21150)) //<Andrew Clark>//
- **[b48b38af6](facebook/react@b48b38af6 )**: Support nesting of startTransition and flushSync (alt) ([#21149](facebook/react#21149)) //<Sebastian Markbåge>//

Changelog:
[General][Changed] - React Native sync for revisions c9aab1c...f7cdc89

jest_e2e[run_all_tests]

Reviewed By: rickhanlonii

Differential Revision: D27740113

fbshipit-source-id: 6e27204d78e3e16ed205170006cb97c0d6bfa957
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
This commit contains a proposed change to layout effect semantics within Suspense subtrees: If a component mounts within a Suspense boundary and is later hidden (because of something else suspending) React will cleanup that component’s layout effects (including React-managed refs).

This change will hopefully fix existing bugs that occur because of things like reading layout in a hidden tree and will also enable a point at which to e.g. pause videos and hide user-managed portals. After the suspended boundary resolves, React will setup the component’s layout effects again (including React-managed refs).

The scenario described above is not common. The useTransition API should ensure that Suspense does not revert to its fallback state after being mounted.

Note that these changes are primarily written in terms of the (as of yet internal) Offscreen API as we intend to provide similar effects semantics within recently shown/hidden Offscreen trees in the future. (More to follow.)

(Note that all changes in this PR are behind a new feature flag, enableSuspenseLayoutEffectSemantics, which is disabled for now.)
@gaearon gaearon mentioned this pull request Mar 29, 2022
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.

None yet

6 participants