react icon indicating copy to clipboard operation
react copied to clipboard

[RN] Use microtasks in the RN renderer based on a global flag defined by RN

Open rubennorte opened this issue 2 years ago • 1 comments

Summary

We want to enable the new event loop in React Native (https://github.com/react-native-community/discussions-and-proposals/pull/744) for all users in the new architecture (determined by the use of bridgeless, not by the use of Fabric). In order to leverage that, we need to also set the flag for the React reconciler to use microtasks for scheduling (so we'll execute them at the right time in the new event loop).

This migrates from the previous approach using a dynamic flag (to be used at Meta) with the check of a global set by React Native. The reason for doing this is:

  1. We still need to determine this dynamically in OSS (based on Bridgeless, not on Fabric).
  2. We still need the ability to configure the behavior at Meta, and for internal build system reasons we cannot access the flag that enables microtasks in ReactNativeFeatureFlags.

How did you test this change?

Manually synchronized the changes to React Native and ran all tests for the new architecture on it. Also tested manually.

[!CAUTION] This shouldn't be merged and synchronized to react-native until https://github.com/facebook/react-native/pull/43397 is merged

rubennorte avatar Feb 29 '24 14:02 rubennorte

Comparing: dfaed5582550f11b27aae967a8e7084202dd2d90...90c9589798adf5f7109b1ef55fa6a5ac102c63f7

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 = 177.10 kB 177.10 kB = 55.20 kB 55.20 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.64 kB 177.64 kB = 55.53 kB 55.53 kB
facebook-www/ReactDOM-prod.classic.js = 594.34 kB 594.34 kB = 104.96 kB 104.96 kB
facebook-www/ReactDOM-prod.modern.js = 577.60 kB 577.60 kB = 102.02 kB 102.02 kB
test_utils/ReactAllWarnings.js Deleted 66.60 kB 0.00 kB Deleted 16.28 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 66.60 kB 0.00 kB Deleted 16.28 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against 90c9589798adf5f7109b1ef55fa6a5ac102c63f7

react-sizebot avatar Feb 29 '24 14:02 react-sizebot