Skip to content

Split recent passive effects changes into 2 flags #18030

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2020

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Feb 12, 2020

Separate flags can now be used to opt passive effects into:

  1. deferPassiveEffectCleanupDuringUnmount: Defer passive effect destroy functions on unmount to subsequent passive effects flush. (Flush useEffect clean up functions in the passive effects phase #17925)
  2. runAllPassiveEffectDestroysBeforeCreates: Running all passive effect destroy functions (for all fibers) before create functions. (Flush all passive destroy fns before calling create fns #17947)

This allows us to test the less risky feature (#17947) separately from the more risky one.

Note that:

  • deferPassiveEffectCleanupDuringUnmount is ignored unless runAllPassiveEffectDestroysBeforeCreates is also enabled.
  • Both flags remain off for the open source release.

I've updated a couple of tests that were impacted by the change to explicitly test with both feature flag values so we don't have blind spots.

Be sure to use the ?w=1 param to see the significant lines changed (+393 −99 rather than +5,471 −5,177).

Separate flags can now be used to opt passive effects into:
1) Deferring destroy functions on unmount to subsequent passive effects flush
2) Running all destroy functions (for all fibers) before create functions

This allows us to test the less risky feature (2) separately from the more risky one.
@bvaughn bvaughn force-pushed the split-passive-effect-flags branch from 6d0aace to 15c91fc Compare February 12, 2020 23:06
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 12, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 12, 2020

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 5897bd4:

Sandbox Source
sharp-engelbart-rzmz9 Configuration

// Controls behavior of deferred effect destroy functions during unmount.
// Previously these functions were run during commit (along with layout effects).
// Ideally we should delay these until after commit for performance reasons.
// This flag provides a killswitch if that proves to break existing code somehow.
//
// WARNING Only enable this flag in conjunction with runAllPassiveEffectDestroysBeforeCreates.
Copy link
Contributor Author

@bvaughn bvaughn Feb 12, 2020

Choose a reason for hiding this comment

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

This constraint is a little gross ☹️ but it keeps the branching complexity low.

Unit tests failures in ReactHooksWithNoopRenderer and ReactSuspenseWithNoopRenderer will prevent us from accidentally using an invalid combination.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of two booleans you could use an enum, to prevent the invalid combination

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I considered that but our precedent has always been booleans for flags.

I don't feel strongly about this though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternative, in the code, you could also check for both booleans before you enable the "defer unmounts" feature.

Just want to make it harder for someone to accidentally toggle the wrong combination of GKs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I hear you. That seems reasonable.

@sizebot
Copy link

sizebot commented Feb 12, 2020

Details of bundled changes.

Comparing: 58b8797...5897bd4

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +0.4% +0.6% 114.67 KB 115.13 KB 29.35 KB 29.51 KB UMD_DEV
react.development.js +0.6% +0.8% 74.18 KB 74.64 KB 19.64 KB 19.8 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 611.85 KB 612.41 KB 129.09 KB 129.27 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 69.98 KB 69.98 KB 20.99 KB 20.99 KB NODE_PROD
react-art.development.js +0.1% +0.1% 681.17 KB 681.74 KB 146.52 KB 146.68 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 104.98 KB 104.98 KB 31.84 KB 31.84 KB UMD_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-test-utils.development.js +0.9% +1.0% 53.65 KB 54.11 KB 15.27 KB 15.42 KB NODE_DEV
react-dom-testing.development.js 0.0% 0.0% 960.41 KB 960.52 KB 215.03 KB 215.07 KB NODE_DEV
react-dom.development.js +0.1% +0.1% 962.99 KB 963.56 KB 216.03 KB 216.2 KB NODE_DEV
react-dom-server.browser.development.js +0.3% +0.4% 139.3 KB 139.76 KB 36.94 KB 37.09 KB UMD_DEV
react-dom-server.browser.development.js +0.3% +0.4% 135.23 KB 135.7 KB 35.92 KB 36.06 KB NODE_DEV
react-dom-test-utils.development.js +0.8% +0.9% 55.38 KB 55.84 KB 15.59 KB 15.73 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 11.2 KB 11.2 KB 4.16 KB 4.16 KB UMD_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.2 KB 1.2 KB 690 B 691 B NODE_PROD
react-dom-server.node.development.js +0.3% +0.4% 136.34 KB 136.8 KB 36.14 KB 36.29 KB NODE_DEV
react-dom-testing.development.js 0.0% 0.0% 966.33 KB 966.43 KB 216.72 KB 216.77 KB UMD_DEV
react-dom-testing.production.min.js 0.0% 0.0% 117.12 KB 117.12 KB 37.76 KB 37.76 KB UMD_PROD
react-dom.development.js +0.1% +0.1% 968.91 KB 969.48 KB 217.69 KB 217.87 KB UMD_DEV

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler-tracing.development.js +3.9% +4.9% 11.96 KB 12.43 KB 3.09 KB 3.25 KB NODE_DEV
scheduler-unstable_mock.development.js 0.0% 0.0% 22.65 KB 22.65 KB 5.4 KB 5.4 KB UMD_DEV
scheduler-unstable_mock.production.min.js 0.0% -0.0% 4.71 KB 4.71 KB 1.97 KB 1.97 KB UMD_PROD
scheduler-unstable_mock.production.min.js 0.0% -0.1% 4.7 KB 4.7 KB 1.91 KB 1.9 KB NODE_PROD
scheduler-tracing.production.min.js 0.0% 🔺+0.3% 728 B 728 B 383 B 384 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-reflection.development.js +2.3% +2.2% 19.93 KB 20.4 KB 6.56 KB 6.71 KB NODE_DEV
react-reconciler-persistent.development.js 0.0% 0.0% 614.75 KB 614.86 KB 128.34 KB 128.38 KB NODE_DEV
react-reconciler.development.js +0.1% +0.1% 617.97 KB 618.54 KB 129.68 KB 129.85 KB NODE_DEV
react-reconciler.production.min.js 0.0% -0.0% 73.73 KB 73.73 KB 21.77 KB 21.77 KB NODE_PROD

Size changes (stable)

Generated by 🚫 dangerJS against 5897bd4

@sizebot
Copy link

sizebot commented Feb 12, 2020

Details of bundled changes.

Comparing: 58b8797...5897bd4

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +0.4% +0.6% 114.69 KB 115.15 KB 29.35 KB 29.51 KB UMD_DEV
react.development.js +0.6% +0.8% 74.2 KB 74.66 KB 19.65 KB 19.8 KB NODE_DEV
react.production.min.js 0.0% 0.0% 6.96 KB 6.96 KB 2.86 KB 2.86 KB NODE_PROD
React-dev.js +0.1% +0.1% 74.19 KB 74.29 KB 18.85 KB 18.87 KB FB_WWW_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-test-utils.development.js +0.8% +0.9% 55.39 KB 55.85 KB 15.6 KB 15.74 KB UMD_DEV
react-dom-testing.profiling.min.js 0.0% -0.0% 121.42 KB 121.42 KB 38.35 KB 38.35 KB NODE_PROFILING
ReactDOMTesting-prod.js 0.0% -0.0% 341.24 KB 341.24 KB 62.28 KB 62.28 KB FB_WWW_PROD
react-dom-server.browser.development.js +0.3% +0.4% 139.32 KB 139.79 KB 36.94 KB 37.09 KB UMD_DEV
react-dom-test-utils.development.js +0.9% +1.0% 53.66 KB 54.13 KB 15.27 KB 15.42 KB NODE_DEV
react-dom-server.browser.development.js +0.3% +0.4% 135.26 KB 135.72 KB 35.92 KB 36.07 KB NODE_DEV
react-dom.development.js +0.1% +0.1% 968.93 KB 969.5 KB 217.71 KB 217.89 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 120 KB 120 KB 38.39 KB 38.39 KB UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 123.63 KB 123.63 KB 39.59 KB 39.59 KB UMD_PROFILING
react-dom.development.js +0.1% +0.1% 963.01 KB 963.58 KB 216.04 KB 216.22 KB NODE_DEV
ReactTestUtils-dev.js +0.2% +0.2% 52.66 KB 52.76 KB 14.34 KB 14.37 KB FB_WWW_DEV
ReactDOMServer-dev.js +0.1% +0.1% 140.41 KB 140.5 KB 35.54 KB 35.57 KB FB_WWW_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.21 KB 1.21 KB 698 B 699 B NODE_PROD
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
ReactDOM-dev.js 0.0% 0.0% 990.33 KB 990.52 KB 218.5 KB 218.55 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 🔺+0.1% 395.6 KB 395.78 KB 71.89 KB 71.94 KB FB_WWW_PROD
react-dom-testing.development.js 0.0% 0.0% 966.35 KB 966.46 KB 216.73 KB 216.78 KB UMD_DEV
ReactDOM-profiling.js 0.0% +0.1% 406.93 KB 407.11 KB 73.99 KB 74.03 KB FB_WWW_PROFILING
react-dom-testing.profiling.min.js 0.0% -0.0% 121.17 KB 121.17 KB 39.04 KB 39.04 KB UMD_PROFILING
react-dom-testing.development.js 0.0% 0.0% 960.43 KB 960.54 KB 215.04 KB 215.09 KB NODE_DEV
react-dom-server.node.development.js +0.3% +0.4% 136.37 KB 136.83 KB 36.15 KB 36.3 KB NODE_DEV
ReactDOMTesting-dev.js 0.0% 0.0% 989.03 KB 989.17 KB 218.09 KB 218.13 KB FB_WWW_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js 0.0% 0.0% 614.76 KB 614.87 KB 128.35 KB 128.39 KB NODE_DEV
react-reconciler-reflection.development.js +2.3% +2.2% 19.95 KB 20.41 KB 6.56 KB 6.71 KB NODE_DEV
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 +0.1% +0.1% 617.98 KB 618.55 KB 129.68 KB 129.85 KB NODE_DEV

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler-tracing.development.js +3.9% +4.9% 11.98 KB 12.44 KB 3.1 KB 3.25 KB NODE_DEV
scheduler-tracing.production.min.js 0.0% 🔺+0.3% 741 B 741 B 391 B 392 B NODE_PROD
scheduler-tracing.profiling.min.js 0.0% +0.1% 3.26 KB 3.26 KB 1002 B 1003 B NODE_PROFILING
scheduler-unstable_mock.production.min.js 0.0% 🔺+0.1% 4.71 KB 4.71 KB 1.91 KB 1.91 KB NODE_PROD
SchedulerTracing-dev.js +1.0% +1.3% 9.93 KB 10.02 KB 2.14 KB 2.17 KB FB_WWW_DEV
scheduler.development.js 0.0% 0.0% 25.29 KB 25.29 KB 6.48 KB 6.48 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 681.2 KB 681.76 KB 146.52 KB 146.68 KB UMD_DEV
react-art.production.min.js 0.0% -0.0% 107.54 KB 107.54 KB 32.53 KB 32.53 KB UMD_PROD
react-art.development.js +0.1% +0.1% 611.87 KB 612.44 KB 129.1 KB 129.27 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 72.5 KB 72.5 KB 21.67 KB 21.66 KB NODE_PROD
ReactART-dev.js 0.0% 0.0% 624.68 KB 624.86 KB 128.99 KB 129.04 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 240.07 KB 240.27 KB 40.4 KB 40.45 KB FB_WWW_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against 5897bd4

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

Reviewed with w=1, looks good to me!

act = ReactNoop.act;
}

[true, false].forEach(deferPassiveEffectCleanupDuringUnmount => {
Copy link
Contributor

Choose a reason for hiding this comment

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

wow function
much pure

@bvaughn bvaughn merged commit 691096c into facebook:master Feb 18, 2020
@bvaughn bvaughn deleted the split-passive-effect-flags branch February 18, 2020 22:19
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.

7 participants