mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Clean up disableEventLoopOnBridgeless feature flag (#49065)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49065 Changelog: [internal] Cleaning up the flag because it's no longer necessary. Reviewed By: sammy-SC Differential Revision: D68892995 fbshipit-source-id: 4e0290bfb11181dc388e6590af1b82581588b9ee
This commit is contained in:
1 parent
4101a2f0b6
commit
82cc465645
6 files changed
+51
-97
No files matched your search
+47
-68
@@ -10,9 +10,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const ReactNativeFeatureFlags = require('../../src/private/featureflags/ReactNativeFeatureFlags');
|
||||
const NativeReactNativeFeatureFlags =
|
||||
require('../../src/private/featureflags/specs/NativeReactNativeFeatureFlags').default;
|
||||
const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
|
||||
|
||||
if (__DEV__) {
|
||||
@@ -21,19 +18,46 @@ if (__DEV__) {
|
||||
}
|
||||
}
|
||||
|
||||
const isEventLoopEnabled = (() => {
|
||||
if (NativeReactNativeFeatureFlags == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
ReactNativeFeatureFlags.enableBridgelessArchitecture() &&
|
||||
!ReactNativeFeatureFlags.disableEventLoopOnBridgeless()
|
||||
);
|
||||
})();
|
||||
|
||||
// In bridgeless mode, timers are host functions installed from cpp.
|
||||
if (global.RN$Bridgeless !== true) {
|
||||
if (global.RN$Bridgeless === true) {
|
||||
// This is the flag that tells React to use `queueMicrotask` to batch state
|
||||
// updates, instead of using the scheduler to schedule a regular task.
|
||||
// We use a global variable because we don't currently have any other
|
||||
// mechanism to pass feature flags from RN to React in OSS.
|
||||
global.RN$enableMicrotasksInReact = true;
|
||||
|
||||
polyfillGlobal(
|
||||
'queueMicrotask',
|
||||
() =>
|
||||
require('../../src/private/webapis/microtasks/specs/NativeMicrotasks')
|
||||
.default.queueMicrotask,
|
||||
);
|
||||
|
||||
// We shim the immediate APIs via `queueMicrotask` to maintain the backward
|
||||
// compatibility.
|
||||
polyfillGlobal(
|
||||
'setImmediate',
|
||||
() => require('./Timers/immediateShim').setImmediate,
|
||||
);
|
||||
polyfillGlobal(
|
||||
'clearImmediate',
|
||||
() => require('./Timers/immediateShim').clearImmediate,
|
||||
);
|
||||
|
||||
polyfillGlobal(
|
||||
'requestIdleCallback',
|
||||
() =>
|
||||
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
||||
.default.requestIdleCallback,
|
||||
);
|
||||
|
||||
polyfillGlobal(
|
||||
'cancelIdleCallback',
|
||||
() =>
|
||||
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
||||
.default.cancelIdleCallback,
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* Set up timers.
|
||||
* You can use this module directly, or just require InitializeCore.
|
||||
@@ -59,50 +83,7 @@ if (global.RN$Bridgeless !== true) {
|
||||
defineLazyTimer('cancelAnimationFrame');
|
||||
defineLazyTimer('requestIdleCallback');
|
||||
defineLazyTimer('cancelIdleCallback');
|
||||
} else if (isEventLoopEnabled) {
|
||||
polyfillGlobal(
|
||||
'requestIdleCallback',
|
||||
() =>
|
||||
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
||||
.default.requestIdleCallback,
|
||||
);
|
||||
|
||||
polyfillGlobal(
|
||||
'cancelIdleCallback',
|
||||
() =>
|
||||
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
||||
.default.cancelIdleCallback,
|
||||
);
|
||||
}
|
||||
|
||||
// We need to check if the native module is available before accessing the
|
||||
// feature flag, because otherwise the API would throw an error in the legacy
|
||||
// architecture in OSS, where the native module isn't available.
|
||||
if (isEventLoopEnabled) {
|
||||
// This is the flag that tells React to use `queueMicrotask` to batch state
|
||||
// updates, instead of using the scheduler to schedule a regular task.
|
||||
// We use a global variable because we don't currently have any other
|
||||
// mechanism to pass feature flags from RN to React in OSS.
|
||||
global.RN$enableMicrotasksInReact = true;
|
||||
|
||||
polyfillGlobal(
|
||||
'queueMicrotask',
|
||||
() =>
|
||||
require('../../src/private/webapis/microtasks/specs/NativeMicrotasks')
|
||||
.default.queueMicrotask,
|
||||
);
|
||||
|
||||
// We shim the immediate APIs via `queueMicrotask` to maintain the backward
|
||||
// compatibility.
|
||||
polyfillGlobal(
|
||||
'setImmediate',
|
||||
() => require('./Timers/immediateShim').setImmediate,
|
||||
);
|
||||
polyfillGlobal(
|
||||
'clearImmediate',
|
||||
() => require('./Timers/immediateShim').clearImmediate,
|
||||
);
|
||||
} else {
|
||||
// Polyfill it with promise (regardless it's polyfilled or native) otherwise.
|
||||
polyfillGlobal(
|
||||
'queueMicrotask',
|
||||
@@ -112,14 +93,12 @@ if (isEventLoopEnabled) {
|
||||
// When promise was polyfilled hence is queued to the RN microtask queue,
|
||||
// we polyfill the immediate APIs as aliases to the ReactNativeMicrotask APIs.
|
||||
// Note that in bridgeless mode, immediate APIs are installed from cpp.
|
||||
if (global.RN$Bridgeless !== true) {
|
||||
polyfillGlobal(
|
||||
'setImmediate',
|
||||
() => require('./Timers/JSTimers').default.queueReactNativeMicrotask,
|
||||
);
|
||||
polyfillGlobal(
|
||||
'clearImmediate',
|
||||
() => require('./Timers/JSTimers').default.clearReactNativeMicrotask,
|
||||
);
|
||||
}
|
||||
polyfillGlobal(
|
||||
'setImmediate',
|
||||
() => require('./Timers/JSTimers').default.queueReactNativeMicrotask,
|
||||
);
|
||||
polyfillGlobal(
|
||||
'clearImmediate',
|
||||
() => require('./Timers/JSTimers').default.clearReactNativeMicrotask,
|
||||
);
|
||||
}
|
||||
+1
-8
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<6b314d87b09e65d8c70a0d3f4caf953a>>
|
||||
* @generated SignedSource<<0d5df5cac07efb95bfd5f0984f960a0b>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -49,13 +49,6 @@ bool NativeReactNativeFeatureFlags::commonTestFlagWithoutNativeImplementation(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NativeReactNativeFeatureFlags::disableEventLoopOnBridgeless(
|
||||
jsi::Runtime& /*runtime*/) {
|
||||
// This flag is configured with `skipNativeAPI: true`.
|
||||
// TODO(T204838867): Implement support for optional methods in C++ TM codegen and remove the method definition altogether.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NativeReactNativeFeatureFlags::disableMountItemReorderingAndroid(
|
||||
jsi::Runtime& /*runtime*/) {
|
||||
return ReactNativeFeatureFlags::disableMountItemReorderingAndroid();
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<3b3ce0cfc8578f517393b89dc76a9aac>>
|
||||
* @generated SignedSource<<44a75d78e4910acb405e79e9953f563a>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -39,8 +39,6 @@ class NativeReactNativeFeatureFlags
|
||||
|
||||
bool commonTestFlagWithoutNativeImplementation(jsi::Runtime& runtime);
|
||||
|
||||
bool disableEventLoopOnBridgeless(jsi::Runtime& runtime);
|
||||
|
||||
bool disableMountItemReorderingAndroid(jsi::Runtime& runtime);
|
||||
|
||||
bool enableAccumulatedUpdatesInRawPropsAndroid(jsi::Runtime& runtime);
|
||||
|
||||
@@ -57,16 +57,6 @@ const testDefinitions: FeatureFlagDefinitions = {
|
||||
const definitions: FeatureFlagDefinitions = {
|
||||
common: {
|
||||
...testDefinitions.common,
|
||||
disableEventLoopOnBridgeless: {
|
||||
defaultValue: false,
|
||||
metadata: {
|
||||
description:
|
||||
'The bridgeless architecture enables the event loop by default. This feature flag allows us to force disabling it in specific instances.',
|
||||
expectedReleaseValue: true,
|
||||
purpose: 'release',
|
||||
},
|
||||
skipNativeAPI: true,
|
||||
},
|
||||
disableMountItemReorderingAndroid: {
|
||||
defaultValue: false,
|
||||
metadata: {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<fdb43dd2f218d9e7d30946ee2f895619>>
|
||||
* @generated SignedSource<<7d66477e7b024c551085f068a6445014>>
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
@@ -50,7 +50,6 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
|
||||
...ReactNativeFeatureFlagsJsOnly,
|
||||
commonTestFlag: Getter<boolean>,
|
||||
commonTestFlagWithoutNativeImplementation: Getter<boolean>,
|
||||
disableEventLoopOnBridgeless: Getter<boolean>,
|
||||
disableMountItemReorderingAndroid: Getter<boolean>,
|
||||
enableAccumulatedUpdatesInRawPropsAndroid: Getter<boolean>,
|
||||
enableBridgelessArchitecture: Getter<boolean>,
|
||||
@@ -176,10 +175,6 @@ export const commonTestFlag: Getter<boolean> = createNativeFlagGetter('commonTes
|
||||
* Common flag for testing (without native implementation). Do NOT modify.
|
||||
*/
|
||||
export const commonTestFlagWithoutNativeImplementation: Getter<boolean> = createNativeFlagGetter('commonTestFlagWithoutNativeImplementation', false, true);
|
||||
/**
|
||||
* The bridgeless architecture enables the event loop by default. This feature flag allows us to force disabling it in specific instances.
|
||||
*/
|
||||
export const disableEventLoopOnBridgeless: Getter<boolean> = createNativeFlagGetter('disableEventLoopOnBridgeless', false, true);
|
||||
/**
|
||||
* Prevent FabricMountingManager from reordering mountitems, which may lead to invalid state on the UI thread
|
||||
*/
|
||||
|
||||
+1
-2
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<c23785c59894d331228bece04fe3a868>>
|
||||
* @generated SignedSource<<73d10e1985377162b75ee60e5bcad8dd>>
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,6 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
|
||||
export interface Spec extends TurboModule {
|
||||
+commonTestFlag?: () => boolean;
|
||||
+commonTestFlagWithoutNativeImplementation?: () => boolean;
|
||||
+disableEventLoopOnBridgeless?: () => boolean;
|
||||
+disableMountItemReorderingAndroid?: () => boolean;
|
||||
+enableAccumulatedUpdatesInRawPropsAndroid?: () => boolean;
|
||||
+enableBridgelessArchitecture?: () => boolean;
|
||||
|
||||
Reference in new issue
Block a user