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

Mount/unmount passive effects when Offscreen visibility changes #24977

Merged

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Jul 22, 2022

Based on #24967

^ review that one first. Or you can review the whole stack commit-by-commit.

This changes the behavior of Offscreen so that passive effects are unmounted when the tree is hidden, and re-mounted when the tree is revealed again. This is already how layout effects worked.

In the future we will likely add an option or heuristic to only unmount the effects of a hidden tree after a delay. That way if the tree quickly switches back to visible, we can skip toggling the effects entirely.

This change does not apply to suspended trees, which happen to use the Offscreen fiber type as an implementation detail. Passive effects remain mounted while the tree is suspended, for the reason described above — it's likely that the suspended tree will resolve and switch back to visible within a short time span.

At a high level, what this capability enables is a feature we refer to as "resuable state". The real value proposition here isn't so much the behavior of effects — it's that you can switch back to a previously rendered tree without losing the state of the UI.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 22, 2022
@sizebot
Copy link

sizebot commented Jul 22, 2022

Comparing: 4ea064e...e582972

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 +0.38% 133.60 kB 134.11 kB +0.20% 42.83 kB 42.92 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.35% 139.17 kB 139.67 kB +0.19% 44.45 kB 44.53 kB
facebook-www/ReactDOM-prod.classic.js +0.31% 474.61 kB 476.08 kB +0.18% 84.81 kB 84.97 kB
facebook-www/ReactDOM-prod.modern.js +0.32% 459.85 kB 461.32 kB +0.19% 82.57 kB 82.73 kB
facebook-www/ReactDOMForked-prod.classic.js +0.31% 474.61 kB 476.08 kB +0.18% 84.81 kB 84.97 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-art/cjs/react-art.production.min.js +0.60% 83.47 kB 83.97 kB +0.35% 25.96 kB 26.05 kB
oss-stable/react-art/cjs/react-art.production.min.js +0.60% 83.49 kB 84.00 kB +0.35% 25.96 kB 26.05 kB
oss-experimental/react-art/cjs/react-art.production.min.js +0.56% 88.58 kB 89.07 kB +0.30% 27.44 kB 27.52 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.production.min.js +0.56% 90.74 kB 91.24 kB +0.30% 28.06 kB 28.14 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.production.min.js +0.56% 90.76 kB 91.26 kB +0.30% 28.06 kB 28.14 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.production.min.js +0.55% 90.99 kB 91.49 kB +0.32% 28.46 kB 28.55 kB
oss-stable/react-test-renderer/umd/react-test-renderer.production.min.js +0.55% 91.01 kB 91.52 kB +0.33% 28.46 kB 28.55 kB
react-native/implementations/ReactFabric-prod.js +0.53% 304.20 kB 305.81 kB +0.34% 53.97 kB 54.15 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.production.min.js +0.53% 94.79 kB 95.30 kB +0.32% 29.16 kB 29.25 kB
oss-stable/react-reconciler/cjs/react-reconciler.production.min.js +0.53% 94.82 kB 95.32 kB +0.32% 29.18 kB 29.27 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.53% 275.60 kB 277.06 kB +0.30% 49.05 kB 49.20 kB
react-native/implementations/ReactFabric-prod.fb.js +0.52% 312.54 kB 314.16 kB +0.34% 55.60 kB 55.78 kB
react-native/implementations/ReactNativeRenderer-prod.js +0.52% 311.01 kB 312.62 kB +0.30% 55.08 kB 55.24 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.min.js +0.52% 95.49 kB 95.99 kB +0.28% 29.44 kB 29.53 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.production.min.js +0.51% 95.74 kB 96.23 kB +0.27% 29.83 kB 29.91 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js +0.51% 319.34 kB 320.95 kB +0.30% 56.70 kB 56.87 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.min.js +0.49% 99.98 kB 100.48 kB +0.30% 30.66 kB 30.76 kB
facebook-www/ReactART-prod.modern.js +0.49% 301.02 kB 302.48 kB +0.31% 51.90 kB 52.06 kB
facebook-www/ReactART-prod.classic.js +0.47% 311.85 kB 313.32 kB +0.29% 53.75 kB 53.90 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.profiling.min.js +0.46% 103.67 kB 104.15 kB +0.24% 31.41 kB 31.49 kB
oss-stable/react-reconciler/cjs/react-reconciler.profiling.min.js +0.46% 103.69 kB 104.17 kB +0.24% 31.43 kB 31.51 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.min.js +0.44% 108.88 kB 109.36 kB +0.28% 32.87 kB 32.96 kB
oss-stable-semver/react-art/umd/react-art.production.min.js +0.42% 119.34 kB 119.85 kB +0.25% 37.19 kB 37.28 kB
oss-stable/react-art/umd/react-art.production.min.js +0.42% 119.37 kB 119.87 kB +0.25% 37.19 kB 37.28 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.41% 290.71 kB 291.91 kB +0.27% 51.30 kB 51.44 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.development.js +0.41% 706.10 kB 708.98 kB +0.19% 147.82 kB 148.10 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js +0.41% 706.12 kB 709.01 kB +0.19% 147.85 kB 148.13 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js +0.41% 674.04 kB 676.79 kB +0.18% 146.21 kB 146.48 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js +0.41% 674.06 kB 676.82 kB +0.18% 146.23 kB 146.50 kB
react-native/implementations/ReactFabric-profiling.js +0.41% 323.15 kB 324.46 kB +0.28% 57.11 kB 57.27 kB
react-native/implementations/ReactNativeRenderer-profiling.js +0.40% 330.01 kB 331.32 kB +0.25% 58.17 kB 58.32 kB
oss-experimental/react-art/umd/react-art.production.min.js +0.40% 124.42 kB 124.91 kB +0.28% 38.60 kB 38.70 kB
oss-stable-semver/react-art/cjs/react-art.development.js +0.39% 701.16 kB 703.92 kB +0.17% 151.13 kB 151.39 kB
oss-stable/react-art/cjs/react-art.development.js +0.39% 701.19 kB 703.94 kB +0.17% 151.15 kB 151.41 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js +0.39% 736.38 kB 739.27 kB +0.18% 153.52 kB 153.79 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js +0.39% 702.89 kB 705.64 kB +0.19% 151.86 kB 152.14 kB
react-native/implementations/ReactFabric-profiling.fb.js +0.39% 339.50 kB 340.82 kB +0.28% 59.80 kB 59.97 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.39% 717.36 kB 720.14 kB +0.20% 153.46 kB 153.76 kB
react-native/implementations/ReactNativeRenderer-profiling.fb.js +0.38% 346.35 kB 347.67 kB +0.25% 60.84 kB 60.99 kB
oss-stable-semver/react-dom/cjs/react-dom.production.min.js +0.38% 133.58 kB 134.08 kB +0.20% 42.83 kB 42.92 kB
oss-stable/react-dom/cjs/react-dom.production.min.js +0.38% 133.60 kB 134.11 kB +0.20% 42.83 kB 42.92 kB
oss-experimental/react-art/cjs/react-art.development.js +0.38% 731.82 kB 734.57 kB +0.17% 157.32 kB 157.59 kB
facebook-www/ReactTestRenderer-dev.modern.js +0.38% 739.53 kB 742.32 kB +0.19% 157.56 kB 157.87 kB
facebook-www/ReactTestRenderer-dev.classic.js +0.38% 739.53 kB 742.32 kB +0.19% 157.56 kB 157.87 kB
oss-stable-semver/react-dom/umd/react-dom.production.min.js +0.38% 133.69 kB 134.19 kB +0.22% 43.48 kB 43.58 kB
oss-stable/react-dom/umd/react-dom.production.min.js +0.38% 133.72 kB 134.22 kB +0.22% 43.48 kB 43.58 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js +0.36% 767.86 kB 770.61 kB +0.16% 163.17 kB 163.44 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js +0.36% 767.88 kB 770.64 kB +0.17% 163.19 kB 163.46 kB
oss-stable-semver/react-art/umd/react-art.development.js +0.36% 805.40 kB 808.29 kB +0.15% 169.28 kB 169.54 kB
oss-stable/react-art/umd/react-art.development.js +0.36% 805.42 kB 808.31 kB +0.16% 169.30 kB 169.56 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.35% 139.17 kB 139.67 kB +0.19% 44.45 kB 44.53 kB
oss-experimental/react-dom/umd/react-dom.production.min.js +0.35% 139.22 kB 139.71 kB +0.19% 45.09 kB 45.17 kB
react-native/implementations/ReactFabric-dev.js +0.35% 794.75 kB 797.54 kB +0.16% 172.10 kB 172.39 kB
react-native/implementations/ReactNativeRenderer-dev.js +0.35% 804.45 kB 807.23 kB +0.17% 174.71 kB 175.00 kB
facebook-www/ReactART-dev.modern.js +0.35% 816.16 kB 818.98 kB +0.19% 172.18 kB 172.52 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.34% 798.79 kB 801.55 kB +0.16% 169.32 kB 169.59 kB
oss-experimental/react-art/umd/react-art.development.js +0.34% 837.53 kB 840.42 kB +0.16% 175.46 kB 175.74 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.min.js +0.34% 144.43 kB 144.93 kB +0.19% 46.51 kB 46.60 kB
facebook-www/ReactART-dev.classic.js +0.34% 826.38 kB 829.20 kB +0.19% 174.32 kB 174.65 kB
react-native/implementations/ReactFabric-dev.fb.js +0.34% 831.83 kB 834.65 kB +0.17% 178.79 kB 179.10 kB
facebook-www/ReactDOMTesting-prod.modern.js +0.34% 434.28 kB 435.74 kB +0.17% 80.21 kB 80.35 kB
oss-stable-semver/react-dom/cjs/react-dom.profiling.min.js +0.34% 143.11 kB 143.59 kB +0.29% 45.28 kB 45.41 kB
oss-stable/react-dom/cjs/react-dom.profiling.min.js +0.34% 143.13 kB 143.61 kB +0.29% 45.28 kB 45.41 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js +0.33% 841.51 kB 844.33 kB +0.17% 181.44 kB 181.75 kB
oss-stable-semver/react-dom/umd/react-dom.profiling.min.js +0.33% 142.55 kB 143.03 kB +0.16% 45.77 kB 45.84 kB
oss-stable/react-dom/umd/react-dom.profiling.min.js +0.33% 142.58 kB 143.06 kB +0.16% 45.76 kB 45.84 kB
facebook-www/ReactDOMTesting-prod.classic.js +0.32% 450.28 kB 451.74 kB +0.17% 82.63 kB 82.77 kB
oss-experimental/react-dom/cjs/react-dom.profiling.min.js +0.32% 148.70 kB 149.18 kB +0.14% 46.89 kB 46.96 kB
facebook-www/ReactDOM-prod.modern.js +0.32% 459.85 kB 461.32 kB +0.19% 82.57 kB 82.73 kB
facebook-www/ReactDOMForked-prod.modern.js +0.32% 459.85 kB 461.32 kB +0.19% 82.57 kB 82.73 kB
oss-experimental/react-dom/umd/react-dom.profiling.min.js +0.32% 148.08 kB 148.55 kB +0.12% 47.36 kB 47.42 kB
facebook-www/ReactDOM-prod.classic.js +0.31% 474.61 kB 476.08 kB +0.18% 84.81 kB 84.97 kB
facebook-www/ReactDOMForked-prod.classic.js +0.31% 474.61 kB 476.08 kB +0.18% 84.81 kB 84.97 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.28% 1,072.81 kB 1,075.86 kB +0.12% 239.35 kB 239.64 kB
facebook-www/ReactDOMTesting-dev.classic.js +0.28% 1,101.43 kB 1,104.48 kB +0.12% 245.16 kB 245.46 kB
oss-stable-semver/react-dom/cjs/react-dom.development.js +0.26% 1,048.26 kB 1,051.02 kB +0.12% 234.35 kB 234.63 kB
oss-stable/react-dom/cjs/react-dom.development.js +0.26% 1,048.29 kB 1,051.04 kB +0.12% 234.37 kB 234.65 kB
oss-stable-semver/react-dom/umd/react-dom.development.js +0.26% 1,099.59 kB 1,102.48 kB +0.11% 236.93 kB 237.19 kB
oss-stable/react-dom/umd/react-dom.development.js +0.26% 1,099.61 kB 1,102.50 kB +0.11% 236.95 kB 237.22 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js +0.26% 1,073.21 kB 1,075.96 kB +0.10% 239.79 kB 240.04 kB
oss-experimental/react-dom/cjs/react-dom.development.js +0.25% 1,081.17 kB 1,083.92 kB +0.11% 241.10 kB 241.37 kB
oss-experimental/react-dom/umd/react-dom.development.js +0.25% 1,134.07 kB 1,136.96 kB +0.11% 243.75 kB 244.03 kB
facebook-www/ReactDOM-profiling.modern.js +0.25% 490.15 kB 491.35 kB +0.18% 87.08 kB 87.23 kB
facebook-www/ReactDOMForked-profiling.modern.js +0.25% 490.15 kB 491.35 kB +0.18% 87.08 kB 87.23 kB
facebook-www/ReactDOM-profiling.classic.js +0.24% 504.97 kB 506.18 kB +0.17% 89.40 kB 89.55 kB
facebook-www/ReactDOMForked-profiling.classic.js +0.24% 504.97 kB 506.18 kB +0.18% 89.40 kB 89.55 kB
facebook-www/ReactDOMForked-dev.modern.js +0.24% 1,188.31 kB 1,191.13 kB +0.13% 260.09 kB 260.42 kB
facebook-www/ReactDOM-dev.modern.js +0.24% 1,188.31 kB 1,191.13 kB +0.13% 260.09 kB 260.42 kB
facebook-www/ReactDOMForked-dev.classic.js +0.23% 1,211.93 kB 1,214.75 kB +0.13% 264.57 kB 264.90 kB
facebook-www/ReactDOM-dev.classic.js +0.23% 1,211.93 kB 1,214.75 kB +0.13% 264.57 kB 264.90 kB

Generated by 🚫 dangerJS against e582972

@acdlite acdlite force-pushed the toggle-passive-effects-on-visibility-change branch 3 times, most recently from b44956c to bbe4813 Compare July 22, 2022 05:08
// For backwards compatibility, don't unmount when a tree suspends. In
// the future we may change this to unmount after a delay.
(finishedWork.return === null ||
finishedWork.return.tag !== SuspenseComponent)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this catch this case <Suspense fallback={<Offscreen>...</Offscreen>}>{...}</Suspense>?

Might be cleaner to just add another "mode" for now that user space can use too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's for the internal Offscreen fiber that Suspense uses. We don't unmount passive effects when there's an avoided fallback.

Yeah I can add a "mode" for that. For the userspace API, I had imagined we might have a way to control the delay for when effects get detached, and one of the options could be "never".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does this catch this case <Suspense fallback={...}>{...}?

Oh I see you're asking if there's a false positive. No because the fallback children are wrapped in an extra Fragment for reconciliation purposes.

acdlite added 4 commits July 29, 2022 19:23
The individual unmount calls are already wrapped in a catch block, so
this outer one serves no purpose.
    
I'm about to add a "disconnect passive effects" function that will share
much of the same code as commitPassiveUnmountOnFiber. To minimize the
duplicated code, I've extracted the shared parts into separate
functions, similar to what I did for commitLayoutEffectOnFiber and
reappearLayoutEffects.

This may not save much on code size because Closure will likely inline
some of it, anyway, but it makes it harder for the two paths to
accidentally diverge.
This changes the behavior of Offscreen so that passive effects are
unmounted when the tree is hidden, and re-mounted when the tree is
revealed again. This is already how layout effects worked.

In the future we will likely add an option or heuristic to only unmount
the effects of a hidden tree after a delay. That way if the tree quickly
switches back to visible, we can skip toggling the effects entirely.

This change does not apply to suspended trees, which happen to use
the Offscreen fiber type as an implementation detail. Passive effects
remain mounted while the tree is suspended, for the reason described
above — it's likely that the suspended tree will resolve and switch
back to visible within a short time span.

At a high level, what this capability enables is a feature we refer to
as "resuable state". The real value proposition here isn't so much the
behavior of effects — it's that you can switch back to a previously
rendered tree without losing the state of the UI.
@acdlite acdlite force-pushed the toggle-passive-effects-on-visibility-change branch from bbe4813 to e582972 Compare July 29, 2022 23:24
@acdlite acdlite merged commit 80f3d88 into facebook:main Jul 29, 2022
@Andarist
Copy link
Contributor

I would have a question here because this is quite interesting for library authors - what are the exact semantics for both layout and passive effects within suspended trees?

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Sep 12, 2022
Summary:
This sync includes the following changes:
- **[c28f313e6](facebook/react@c28f313e6 )**: experimental_use(promise) for SSR ([#25214](facebook/react#25214)) //<Andrew Clark>//
- **[d6f9628a8](facebook/react@d6f9628a8 )**: Remove some RSC subset entry points that were removed in the main entry point ([#25209](facebook/react#25209)) //<Sebastian Markbåge>//
- **[a473d08fc](facebook/react@a473d08fc )**: Update to Flow from 0.97 to 0.122 ([#25204](facebook/react#25204)) //<Jan Kassens>//
- **[7028ce745](facebook/react@7028ce745 )**: experimental_use(promise) for Server Components ([#25207](facebook/react#25207)) //<Andrew Clark>//
- **[bfb65681e](facebook/react@bfb65681e )**: experimental_use(context)([#25202](facebook/react#25202)) //<mofeiZ>//
- **[f0efa1164](facebook/react@f0efa1164 )**: [flow] remove custom suppress comment config ([#25170](facebook/react#25170)) //<Jan Kassens>//
- **[2e7f422fe](facebook/react@2e7f422fe )**: Refactor: its type is Container ([#25153](facebook/react#25153)) //<bubucuo>//
- **[2c2d9a1df](facebook/react@2c2d9a1df )**: [eslint-plugin-react-hooks] only allow capitalized component names ([#25162](facebook/react#25162)) //<Jan Kassens>//
- **[36c908a6c](facebook/react@36c908a6c )**: Don't use the Flight terminology in public error messages ([#25166](facebook/react#25166)) //<Sebastian Markbåge>//
- **[8d1b057ec](facebook/react@8d1b057ec )**: [Flight] Minor error handling fixes ([#25151](facebook/react#25151)) //<Sebastian Markbåge>//
- **[9ff738f53](facebook/react@9ff738f53 )**: [devtools][easy] Fix flow type ([#25147](facebook/react#25147)) //<Tianyu Yao>//
- **[0de3ddf56](facebook/react@0de3ddf56 )**: Remove Symbol Polyfill (again) ([#25144](facebook/react#25144)) //<Ricky>//
- **[b36f72235](facebook/react@b36f72235 )**: Remove ReactFiberFlags MountLayoutDev and MountPassiveDev ([#25091](facebook/react#25091)) //<Samuel Susla>//
- **[b6978bc38](facebook/react@b6978bc38 )**: experimental_use(promise) ([#25084](facebook/react#25084)) //<Andrew Clark>//
- **[11ed7010c](facebook/react@11ed7010c )**: [Transition Tracing] onMarkerIncomplete - Tracing Marker/Suspense Boundary Deletions ([#24885](facebook/react#24885)) //<Luna Ruan>//
- **[b79894259](facebook/react@b79894259 )**: [Flight] Add support for Webpack Async Modules ([#25138](facebook/react#25138)) //<Sebastian Markbåge>//
- **[c8b778b7f](facebook/react@c8b778b7f )**: Fix typo: supportsMicrotask -> supportsMicrotasks ([#25142](facebook/react#25142)) //<kwzr>//
- **[d0f396651](facebook/react@d0f396651 )**: Allow functions to be used as module references ([#25137](facebook/react#25137)) //<Sebastian Markbåge>//
- **[38c5d8a03](facebook/react@38c5d8a03 )**: Test the node-register hooks in unit tests ([#25132](facebook/react#25132)) //<Sebastian Markbåge>//
- **[3f70e68ce](facebook/react@3f70e68ce )**: Return closestInstance in `getInspectorDataForViewAtPoint` ([#25118](facebook/react#25118)) //<Tianyu Yao>//
- **[3d443cad7](facebook/react@3d443cad7 )**: Update fixtures/flight to webpack 5 ([#25115](facebook/react#25115)) //<Tim Neutkens>//
- **[5d1ce6513](facebook/react@5d1ce6513 )**: Align StrictMode behaviour with production ([#25049](facebook/react#25049)) //<Samuel Susla>//
- **[9e67e7a31](facebook/react@9e67e7a31 )**: Scaffolding for useMemoCache hook ([#25123](facebook/react#25123)) //<Joseph Savona>//
- **[19e9a4c68](facebook/react@19e9a4c68 )**: Add missing createServerContext for experimental shared subset ([#25114](facebook/react#25114)) //<Jiachi Liu>//
- **[6ef466c68](facebook/react@6ef466c68 )**: make preamble and postamble types explicit and fix typo ([#25102](facebook/react#25102)) //<Josh Story>//
- **[796d31809](facebook/react@796d31809 )**: Implement basic stylesheet Resources for react-dom ([#25060](facebook/react#25060)) //<Josh Story>//
- **[32baab38f](facebook/react@32baab38f )**: [Transition Tracing] Add Tag Field to Marker Instance ([#25085](facebook/react#25085)) //<Luna Ruan>//
- **[8ef3a7c08](facebook/react@8ef3a7c08 )**: Resume immediately pinged fiber without unwinding ([#25074](facebook/react#25074)) //<Andrew Clark>//
- **[7bcc68772](facebook/react@7bcc68772 )**: Remove argument committedLanes from reappearLayoutEffects and recursivelyTraverseReappearLayoutEffects ([#25080](facebook/react#25080)) //<Samuel Susla>//
- **[ca990e9a7](facebook/react@ca990e9a7 )**: Add API to force Scheduler to yield for macrotask ([#25044](facebook/react#25044)) //<Andrew Clark>//
- **[b4204ede6](facebook/react@b4204ede6 )**: Clean up unused Deletion flag ([#24992](facebook/react#24992)) //<Andrew Clark>//
- **[e193be87e](facebook/react@e193be87e )**: [Transition Tracing] Add Offscreen Test ([#25035](facebook/react#25035)) //<Luna Ruan>//
- **[9fcaf88d5](facebook/react@9fcaf88d5 )**: Remove rootContainerInstance from unnecessary places ([#25024](facebook/react#25024)) //<Sebastian Markbåge>//
- **[80f3d8819](facebook/react@80f3d8819 )**: Mount/unmount passive effects when Offscreen visibility changes ([#24977](facebook/react#24977)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 4ea064e...c28f313

Reviewed By: rickhanlonii

Differential Revision: D39384898

fbshipit-source-id: 20b080a53851d6dd9d522c8468dd02aab9ba76db
rickhanlonii pushed a commit that referenced this pull request Oct 6, 2022
* Remove unnecessary try-catch from passive deletion

The individual unmount calls are already wrapped in a catch block, so
this outer one serves no purpose.

* Extract passive unmount effects to separate functions
    
I'm about to add a "disconnect passive effects" function that will share
much of the same code as commitPassiveUnmountOnFiber. To minimize the
duplicated code, I've extracted the shared parts into separate
functions, similar to what I did for commitLayoutEffectOnFiber and
reappearLayoutEffects.

This may not save much on code size because Closure will likely inline
some of it, anyway, but it makes it harder for the two paths to
accidentally diverge.

* Mount/unmount passive effects on hide/show

This changes the behavior of Offscreen so that passive effects are
unmounted when the tree is hidden, and re-mounted when the tree is
revealed again. This is already how layout effects worked.

In the future we will likely add an option or heuristic to only unmount
the effects of a hidden tree after a delay. That way if the tree quickly
switches back to visible, we can skip toggling the effects entirely.

This change does not apply to suspended trees, which happen to use
the Offscreen fiber type as an implementation detail. Passive effects
remain mounted while the tree is suspended, for the reason described
above — it's likely that the suspended tree will resolve and switch
back to visible within a short time span.

At a high level, what this capability enables is a feature we refer to
as "resuable state". The real value proposition here isn't so much the
behavior of effects — it's that you can switch back to a previously
rendered tree without losing the state of the UI.

* Add more coverage for nested Offscreen cases
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
This sync includes the following changes:
- **[c28f313e6](facebook/react@c28f313e6 )**: experimental_use(promise) for SSR ([facebook#25214](facebook/react#25214)) //<Andrew Clark>//
- **[d6f9628a8](facebook/react@d6f9628a8 )**: Remove some RSC subset entry points that were removed in the main entry point ([facebook#25209](facebook/react#25209)) //<Sebastian Markbåge>//
- **[a473d08fc](facebook/react@a473d08fc )**: Update to Flow from 0.97 to 0.122 ([facebook#25204](facebook/react#25204)) //<Jan Kassens>//
- **[7028ce745](facebook/react@7028ce745 )**: experimental_use(promise) for Server Components ([facebook#25207](facebook/react#25207)) //<Andrew Clark>//
- **[bfb65681e](facebook/react@bfb65681e )**: experimental_use(context)([facebook#25202](facebook/react#25202)) //<mofeiZ>//
- **[f0efa1164](facebook/react@f0efa1164 )**: [flow] remove custom suppress comment config ([facebook#25170](facebook/react#25170)) //<Jan Kassens>//
- **[2e7f422fe](facebook/react@2e7f422fe )**: Refactor: its type is Container ([facebook#25153](facebook/react#25153)) //<bubucuo>//
- **[2c2d9a1df](facebook/react@2c2d9a1df )**: [eslint-plugin-react-hooks] only allow capitalized component names ([facebook#25162](facebook/react#25162)) //<Jan Kassens>//
- **[36c908a6c](facebook/react@36c908a6c )**: Don't use the Flight terminology in public error messages ([facebook#25166](facebook/react#25166)) //<Sebastian Markbåge>//
- **[8d1b057ec](facebook/react@8d1b057ec )**: [Flight] Minor error handling fixes ([facebook#25151](facebook/react#25151)) //<Sebastian Markbåge>//
- **[9ff738f53](facebook/react@9ff738f53 )**: [devtools][easy] Fix flow type ([facebook#25147](facebook/react#25147)) //<Tianyu Yao>//
- **[0de3ddf56](facebook/react@0de3ddf56 )**: Remove Symbol Polyfill (again) ([facebook#25144](facebook/react#25144)) //<Ricky>//
- **[b36f72235](facebook/react@b36f72235 )**: Remove ReactFiberFlags MountLayoutDev and MountPassiveDev ([facebook#25091](facebook/react#25091)) //<Samuel Susla>//
- **[b6978bc38](facebook/react@b6978bc38 )**: experimental_use(promise) ([facebook#25084](facebook/react#25084)) //<Andrew Clark>//
- **[11ed7010c](facebook/react@11ed7010c )**: [Transition Tracing] onMarkerIncomplete - Tracing Marker/Suspense Boundary Deletions ([facebook#24885](facebook/react#24885)) //<Luna Ruan>//
- **[b79894259](facebook/react@b79894259 )**: [Flight] Add support for Webpack Async Modules ([facebook#25138](facebook/react#25138)) //<Sebastian Markbåge>//
- **[c8b778b7f](facebook/react@c8b778b7f )**: Fix typo: supportsMicrotask -> supportsMicrotasks ([facebook#25142](facebook/react#25142)) //<kwzr>//
- **[d0f396651](facebook/react@d0f396651 )**: Allow functions to be used as module references ([facebook#25137](facebook/react#25137)) //<Sebastian Markbåge>//
- **[38c5d8a03](facebook/react@38c5d8a03 )**: Test the node-register hooks in unit tests ([facebook#25132](facebook/react#25132)) //<Sebastian Markbåge>//
- **[3f70e68ce](facebook/react@3f70e68ce )**: Return closestInstance in `getInspectorDataForViewAtPoint` ([facebook#25118](facebook/react#25118)) //<Tianyu Yao>//
- **[3d443cad7](facebook/react@3d443cad7 )**: Update fixtures/flight to webpack 5 ([facebook#25115](facebook/react#25115)) //<Tim Neutkens>//
- **[5d1ce6513](facebook/react@5d1ce6513 )**: Align StrictMode behaviour with production ([facebook#25049](facebook/react#25049)) //<Samuel Susla>//
- **[9e67e7a31](facebook/react@9e67e7a31 )**: Scaffolding for useMemoCache hook ([facebook#25123](facebook/react#25123)) //<Joseph Savona>//
- **[19e9a4c68](facebook/react@19e9a4c68 )**: Add missing createServerContext for experimental shared subset ([facebook#25114](facebook/react#25114)) //<Jiachi Liu>//
- **[6ef466c68](facebook/react@6ef466c68 )**: make preamble and postamble types explicit and fix typo ([facebook#25102](facebook/react#25102)) //<Josh Story>//
- **[796d31809](facebook/react@796d31809 )**: Implement basic stylesheet Resources for react-dom ([facebook#25060](facebook/react#25060)) //<Josh Story>//
- **[32baab38f](facebook/react@32baab38f )**: [Transition Tracing] Add Tag Field to Marker Instance ([facebook#25085](facebook/react#25085)) //<Luna Ruan>//
- **[8ef3a7c08](facebook/react@8ef3a7c08 )**: Resume immediately pinged fiber without unwinding ([facebook#25074](facebook/react#25074)) //<Andrew Clark>//
- **[7bcc68772](facebook/react@7bcc68772 )**: Remove argument committedLanes from reappearLayoutEffects and recursivelyTraverseReappearLayoutEffects ([facebook#25080](facebook/react#25080)) //<Samuel Susla>//
- **[ca990e9a7](facebook/react@ca990e9a7 )**: Add API to force Scheduler to yield for macrotask ([facebook#25044](facebook/react#25044)) //<Andrew Clark>//
- **[b4204ede6](facebook/react@b4204ede6 )**: Clean up unused Deletion flag ([facebook#24992](facebook/react#24992)) //<Andrew Clark>//
- **[e193be87e](facebook/react@e193be87e )**: [Transition Tracing] Add Offscreen Test ([facebook#25035](facebook/react#25035)) //<Luna Ruan>//
- **[9fcaf88d5](facebook/react@9fcaf88d5 )**: Remove rootContainerInstance from unnecessary places ([facebook#25024](facebook/react#25024)) //<Sebastian Markbåge>//
- **[80f3d8819](facebook/react@80f3d8819 )**: Mount/unmount passive effects when Offscreen visibility changes ([facebook#24977](facebook/react#24977)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 4ea064e...c28f313

Reviewed By: rickhanlonii

Differential Revision: D39384898

fbshipit-source-id: 20b080a53851d6dd9d522c8468dd02aab9ba76db
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.

6 participants