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

[Fiber] Extract Functions that Call User Space and Host Configs in Commit to Separate Modules #30881

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

sebmarkbage
Copy link
Collaborator

This is mostly just moves and same code extracted into utility functions.

This is to help clarify what needs to be wrapped in try/catch and runWithFiberInDEV. I'll do the runWithFiberInDEV changes in a follow up.

This leaves ReactCommitWork mostly to do matching on the tag and the recursive loops.

This should really be covered by the inner functions.
The effective change is only that errors in unmount insertion effects don't
abort mount insertion effects.

We probably should abort future phases when earlier phases abort we don't
currently.
Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 11:27pm

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Sep 4, 2024
commitDeletionEffects(root, parentFiber, childToDelete);
} catch (error) {
captureCommitPhaseError(childToDelete, parentFiber, error);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This catch was removed since it should be handled by the individual calls deeper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not all host config methods are wrapped because that would be a lot of them so doesn't seem worth it. E.g. the Float ones could error and take other things along with it.

HookInsertion | HookHasEffect,
finishedWork,
);
} catch (error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This used to be one catch but is now two. So if the unmount throws, we continue with the mount.

That's probably not desirable but consistent with other effects we have atm.

@react-sizebot
Copy link

react-sizebot commented Sep 4, 2024

Comparing: f820f5a...78b9c48

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 +0.05% 1.82 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.32% 503.23 kB 504.83 kB +0.02% 90.22 kB 90.24 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.31% 510.44 kB 512.02 kB +0.03% 91.42 kB 91.45 kB
facebook-www/ReactDOM-prod.classic.js +0.32% 598.56 kB 600.47 kB +0.17% 106.05 kB 106.22 kB
facebook-www/ReactDOM-prod.modern.js +0.33% 574.84 kB 576.76 kB +0.14% 102.22 kB 102.36 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-rc/react-art/cjs/react-art.production.js +0.57% 293.80 kB 295.48 kB +0.39% 50.57 kB 50.76 kB
oss-stable-semver/react-art/cjs/react-art.production.js +0.57% 293.80 kB 295.48 kB +0.39% 50.57 kB 50.76 kB
oss-stable/react-art/cjs/react-art.production.js +0.57% 293.86 kB 295.55 kB +0.39% 50.59 kB 50.79 kB
oss-stable-rc/react-test-renderer/cjs/react-test-renderer.production.js +0.57% 302.98 kB 304.72 kB +0.36% 53.71 kB 53.91 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.production.js +0.57% 302.98 kB 304.72 kB +0.36% 53.71 kB 53.91 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.production.js +0.57% 303.04 kB 304.78 kB +0.37% 53.73 kB 53.93 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.js +0.57% 305.24 kB 306.98 kB +0.37% 54.17 kB 54.37 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.54% 320.47 kB 322.21 kB +0.29% 56.62 kB 56.78 kB
oss-experimental/react-art/cjs/react-art.production.js +0.49% 300.60 kB 302.08 kB +0.31% 51.79 kB 51.95 kB
facebook-www/ReactART-prod.modern.js +0.47% 348.79 kB 350.41 kB +0.21% 59.31 kB 59.43 kB
facebook-www/ReactART-prod.classic.js +0.44% 365.80 kB 367.42 kB +0.19% 62.06 kB 62.18 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js +0.43% 381.19 kB 382.83 kB +0.27% 66.84 kB 67.02 kB
react-native/implementations/ReactNativeRenderer-prod.js +0.38% 357.66 kB 359.01 kB +0.23% 62.75 kB 62.89 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.35% 344.37 kB 345.58 kB +0.25% 60.10 kB 60.25 kB
facebook-www/ReactDOM-prod.modern.js +0.33% 574.84 kB 576.76 kB +0.14% 102.22 kB 102.36 kB
facebook-www/ReactDOMTesting-prod.modern.js +0.32% 589.58 kB 591.49 kB +0.11% 105.95 kB 106.07 kB
facebook-www/ReactDOM-prod.classic.js +0.32% 598.56 kB 600.47 kB +0.17% 106.05 kB 106.22 kB
oss-stable-rc/react-dom/cjs/react-dom-client.production.js +0.32% 503.12 kB 504.72 kB +0.02% 90.20 kB 90.22 kB
oss-stable-semver/react-dom/cjs/react-dom-client.production.js +0.32% 503.12 kB 504.72 kB +0.02% 90.20 kB 90.22 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.32% 503.23 kB 504.83 kB +0.02% 90.22 kB 90.24 kB
facebook-www/ReactDOMTesting-prod.classic.js +0.31% 613.29 kB 615.20 kB +0.14% 109.77 kB 109.92 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.31% 510.44 kB 512.02 kB +0.03% 91.42 kB 91.45 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js +0.30% 525.17 kB 526.75 kB +0.03% 95.10 kB 95.13 kB
react-native/implementations/ReactFabric-prod.js +0.28% 348.33 kB 349.31 kB +0.17% 61.11 kB 61.22 kB
oss-stable-rc/react-art/cjs/react-art.development.js +0.28% 546.63 kB 548.17 kB +0.09% 88.85 kB 88.93 kB
oss-stable-semver/react-art/cjs/react-art.development.js +0.28% 546.63 kB 548.17 kB +0.09% 88.85 kB 88.93 kB
oss-stable/react-art/cjs/react-art.development.js +0.28% 546.70 kB 548.24 kB +0.09% 88.88 kB 88.95 kB
react-native/implementations/ReactFabric-prod.fb.js +0.28% 375.99 kB 377.05 kB +0.20% 65.68 kB 65.81 kB
react-native/implementations/ReactNativeRenderer-profiling.fb.js +0.28% 408.74 kB 409.87 kB +0.18% 71.08 kB 71.21 kB
oss-experimental/react-art/cjs/react-art.development.js +0.27% 560.65 kB 562.16 kB +0.09% 90.69 kB 90.77 kB
oss-stable-rc/react-reconciler/cjs/react-reconciler.production.js +0.27% 379.41 kB 380.42 kB = 62.35 kB 62.35 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.production.js +0.27% 379.41 kB 380.42 kB = 62.35 kB 62.35 kB
oss-stable/react-reconciler/cjs/react-reconciler.production.js +0.27% 379.43 kB 380.44 kB = 62.37 kB 62.37 kB
facebook-www/ReactDOM-profiling.modern.js +0.24% 604.24 kB 605.71 kB +0.14% 106.54 kB 106.69 kB
facebook-www/ReactART-dev.modern.js +0.24% 625.04 kB 626.56 kB +0.22% 100.50 kB 100.72 kB
facebook-www/ReactDOM-profiling.classic.js +0.23% 628.59 kB 630.05 kB +0.16% 110.50 kB 110.68 kB
facebook-www/ReactDOM-dev.modern.js +0.23% 1,044.13 kB 1,046.51 kB +0.14% 175.56 kB 175.80 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.22% 1,061.03 kB 1,063.42 kB +0.13% 179.44 kB 179.67 kB
react-native/implementations/ReactNativeRenderer-profiling.js +0.22% 384.91 kB 385.76 kB +0.17% 66.95 kB 67.07 kB
facebook-www/ReactReconciler-dev.modern.js +0.21% 711.88 kB 713.39 kB +0.16% 113.68 kB 113.86 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js +0.20% 387.44 kB 388.22 kB = 63.71 kB 63.69 kB

Generated by 🚫 dangerJS against 9c64bc7

The release is still not wrapped.
@sebmarkbage sebmarkbage merged commit fe03c56 into facebook:main Sep 6, 2024
184 checks passed
sebmarkbage added a commit that referenced this pull request Sep 6, 2024
Stacked on #30881.

Move `runWithFiberInDEV` from the recursive part of the commit phase and
instead wrap each call into user space. These should really map 1:1 with
where we're using `try/catch` since that's where we're calling into user
space.

The goal of this is to avoid the extra stack frames added by
`enableOwnerStacks` in the recursive parts to avoid stack overflow. This
way we only have a couple of extra at the end of the stack instead of a
couple of extra at every depth of the tree.
github-actions bot pushed a commit that referenced this pull request Sep 6, 2024
…mmit to Separate Modules (#30881)

This is mostly just moves and same code extracted into utility
functions.

This is to help clarify what needs to be wrapped in try/catch and
runWithFiberInDEV. I'll do the runWithFiberInDEV changes in a follow up.

This leaves ReactCommitWork mostly to do matching on the tag and the
recursive loops.

DiffTrain build for commit fe03c56.
github-actions bot pushed a commit that referenced this pull request Sep 6, 2024
…mmit to Separate Modules (#30881)

This is mostly just moves and same code extracted into utility
functions.

This is to help clarify what needs to be wrapped in try/catch and
runWithFiberInDEV. I'll do the runWithFiberInDEV changes in a follow up.

This leaves ReactCommitWork mostly to do matching on the tag and the
recursive loops.

DiffTrain build for [fe03c56](fe03c56)
github-actions bot pushed a commit that referenced this pull request Sep 6, 2024
Stacked on #30881.

Move `runWithFiberInDEV` from the recursive part of the commit phase and
instead wrap each call into user space. These should really map 1:1 with
where we're using `try/catch` since that's where we're calling into user
space.

The goal of this is to avoid the extra stack frames added by
`enableOwnerStacks` in the recursive parts to avoid stack overflow. This
way we only have a couple of extra at the end of the stack instead of a
couple of extra at every depth of the tree.

DiffTrain build for commit a03254b.
github-actions bot pushed a commit that referenced this pull request Sep 6, 2024
Stacked on #30881.

Move `runWithFiberInDEV` from the recursive part of the commit phase and
instead wrap each call into user space. These should really map 1:1 with
where we're using `try/catch` since that's where we're calling into user
space.

The goal of this is to avoid the extra stack frames added by
`enableOwnerStacks` in the recursive parts to avoid stack overflow. This
way we only have a couple of extra at the end of the stack instead of a
couple of extra at every depth of the tree.

DiffTrain build for [a03254b](a03254b)
gnoff pushed a commit to vercel/next.js that referenced this pull request Sep 12, 2024
**breaking change for canary users: Bumps peer dependency of React from
`19.0.0-rc-7771d3a7-20240827` to `19.0.0-rc-94e652d5-20240912`**

[diff
facebook/react@7771d3a7...94e652d5](facebook/react@7771d3a...94e652d)

<details>
<summary>React upstream changes</summary>

- facebook/react#30952
- facebook/react#30950
- facebook/react#30946
- facebook/react#30934
- facebook/react#30947
- facebook/react#30945
- facebook/react#30938
- facebook/react#30936
- facebook/react#30879
- facebook/react#30888
- facebook/react#30931
- facebook/react#30930
- facebook/react#30832
- facebook/react#30929
- facebook/react#30926
- facebook/react#30925
- facebook/react#30905
- facebook/react#30900
- facebook/react#30910
- facebook/react#30906
- facebook/react#30899
- facebook/react#30919
- facebook/react#30708
- facebook/react#30907
- facebook/react#30897
- facebook/react#30896
- facebook/react#30895
- facebook/react#30887
- facebook/react#30889
- facebook/react#30893
- facebook/react#30892
- facebook/react#30891
- facebook/react#30882
- facebook/react#30881
- facebook/react#30870
- facebook/react#30849
- facebook/react#30878
- facebook/react#30865
- facebook/react#30869
- facebook/react#30875
- facebook/react#30800
- facebook/react#30762
- facebook/react#30831
- facebook/react#30866
- facebook/react#30853
- facebook/react#30850
- facebook/react#30847
- facebook/react#30842
- facebook/react#30837
- facebook/react#30848
- facebook/react#30844
- facebook/react#30839
- facebook/react#30802
- facebook/react#30841
- facebook/react#30827
- facebook/react#30826
- facebook/react#30825
- facebook/react#30824
- facebook/react#30840
- facebook/react#30838
- facebook/react#30836
- facebook/react#30819
- facebook/react#30816
- facebook/react#30814
- facebook/react#30813
- facebook/react#30812
- facebook/react#30811

</details>

---------

Co-authored-by: vercel-release-bot <infra+release@vercel.com>
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