Migrate mount hooks flag to new system (#43350)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43350

Changelog: [internal]

Mount hooks have been shipped on iOS, so this removes the flag for them.

On Android, we're still testing them so it's worth moving them to the new system and scoping them to that platform.

Reviewed By: sammy-SC

Differential Revision: D54587740

fbshipit-source-id: d074927fee1a967bd3928970c31975d07cd393bb
This commit is contained in:
Rubén Norte
2024-03-06 12:41:49 -08:00
committed by Facebook GitHub Bot
parent a66f4450e5
commit fafd64e9c3
25 changed files with 129 additions and 36 deletions
@@ -265,10 +265,6 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
CoreFeatures::enableGranularScrollViewStateUpdatesIOS = true;
}
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_mount_hooks_ios")) {
CoreFeatures::enableMountHooks = true;
}
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_cloneless_state_progression")) {
CoreFeatures::enableClonelessStateProgression = true;
}
@@ -1910,7 +1910,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
public static field enableFabricPendingEventQueue Z
public static field enableFabricRenderer Z
public static field enableFabricRendererExclusively Z
public static field enableMountHooks Z
public static field enableRemoveDeleteTreeInstruction Z
public static field enableTextSpannableCache Z
public static field enableViewRecycling Z
@@ -109,9 +109,6 @@ public class ReactFeatureFlags {
*/
public static boolean enableRemoveDeleteTreeInstruction = false;
/** Report mount operations from the host platform to notify mount hooks. */
public static boolean enableMountHooks = false;
/** Use native view configs in bridgeless mode. */
public static boolean useNativeViewConfigsInBridgelessMode = false;
@@ -65,6 +65,7 @@ import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItemFactory;
import com.facebook.react.interfaces.fabric.SurfaceHandler;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.internal.interop.InteropEventEmitter;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.i18nmanager.I18nUtil;
@@ -1220,7 +1221,9 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
listener.didMountItems(FabricUIManager.this);
}
if (!ReactFeatureFlags.enableMountHooks || mountItems == null || mountItems.isEmpty()) {
if (!ReactNativeFeatureFlags.enableMountHooksAndroid()
|| mountItems == null
|| mountItems.isEmpty()) {
return;
}
@@ -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<<6d6fd79bdd221b3aeed0057ac756ee92>>
* @generated SignedSource<<bdd9f28c6de15e64ce03c505a3f4f34b>>
*/
/**
@@ -64,6 +64,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableMicrotasks(): Boolean = accessor.enableMicrotasks()
/**
* Enables the notification of mount operations to mount hooks on Android.
*/
@JvmStatic
public fun enableMountHooksAndroid(): Boolean = accessor.enableMountHooksAndroid()
/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
@@ -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<<45776de0416f833eed9bb84d6b7d1052>>
* @generated SignedSource<<7ae379135157666d9646f1d8eeec9989>>
*/
/**
@@ -26,6 +26,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableFixForClippedSubviewsCrashCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
@@ -85,6 +86,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun enableMountHooksAndroid(): Boolean {
var cached = enableMountHooksAndroidCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableMountHooksAndroid()
enableMountHooksAndroidCache = cached
}
return cached
}
override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
@@ -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<<f9c16b18d93c786db2c5a90c0c4340f6>>
* @generated SignedSource<<244a0656beee8e018585bdd4bb4e5cd1>>
*/
/**
@@ -40,6 +40,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableMicrotasks(): Boolean
@DoNotStrip @JvmStatic public external fun enableMountHooksAndroid(): Boolean
@DoNotStrip @JvmStatic public external fun enableSpannableBuildingUnification(): Boolean
@DoNotStrip @JvmStatic public external fun inspectorEnableCxxInspectorPackagerConnection(): Boolean
@@ -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<<4f72683fb2a832d5b77ee2cb37343526>>
* @generated SignedSource<<d0985b19d61af8bdf47c322b7a59e203>>
*/
/**
@@ -35,6 +35,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableMicrotasks(): Boolean = false
override fun enableMountHooksAndroid(): Boolean = false
override fun enableSpannableBuildingUnification(): Boolean = false
override fun inspectorEnableCxxInspectorPackagerConnection(): Boolean = false
@@ -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<<5fd54183222961f5557dbe0ac111a6ec>>
* @generated SignedSource<<919eb0f27540e5dd7a1e028663c23264>>
*/
/**
@@ -30,6 +30,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableFixForClippedSubviewsCrashCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
@@ -95,6 +96,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableMountHooksAndroid(): Boolean {
var cached = enableMountHooksAndroidCache
if (cached == null) {
cached = currentProvider.enableMountHooksAndroid()
accessedFeatureFlags.add("enableMountHooksAndroid")
enableMountHooksAndroidCache = cached
}
return cached
}
override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
@@ -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<<c4f4d28210d5437839616d49120eb921>>
* @generated SignedSource<<ddbe652a9094bd6af4bdb741fc17ea7c>>
*/
/**
@@ -35,6 +35,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableMicrotasks(): Boolean
@DoNotStrip public fun enableMountHooksAndroid(): Boolean
@DoNotStrip public fun enableSpannableBuildingUnification(): Boolean
@DoNotStrip public fun inspectorEnableCxxInspectorPackagerConnection(): Boolean
@@ -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<<5b40c18d94331e9ec3fdd1a8814b1292>>
* @generated SignedSource<<393c6cf93399cfe0b0533927877531d5>>
*/
/**
@@ -75,6 +75,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool enableMountHooksAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableMountHooksAndroid");
return method(javaProvider_);
}
bool enableSpannableBuildingUnification() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableSpannableBuildingUnification");
@@ -133,6 +139,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableMicrotasks(
return ReactNativeFeatureFlags::enableMicrotasks();
}
bool JReactNativeFeatureFlagsCxxInterop::enableMountHooksAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableMountHooksAndroid();
}
bool JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableSpannableBuildingUnification();
@@ -188,6 +199,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableMicrotasks",
JReactNativeFeatureFlagsCxxInterop::enableMicrotasks),
makeNativeMethod(
"enableMountHooksAndroid",
JReactNativeFeatureFlagsCxxInterop::enableMountHooksAndroid),
makeNativeMethod(
"enableSpannableBuildingUnification",
JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification),
@@ -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<<514446a9fd1351df1f7f3b307de54b56>>
* @generated SignedSource<<e0466f307c37b0c46a09d3a792060fcd>>
*/
/**
@@ -48,6 +48,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableMicrotasks(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableMountHooksAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableSpannableBuildingUnification(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -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<<59573653a5f37505d9a52ac76a9dbcff>>
* @generated SignedSource<<cc7c7aa6ac71f94f8dd8fc8cc0c18308>>
*/
/**
@@ -45,6 +45,10 @@ bool ReactNativeFeatureFlags::enableMicrotasks() {
return getAccessor().enableMicrotasks();
}
bool ReactNativeFeatureFlags::enableMountHooksAndroid() {
return getAccessor().enableMountHooksAndroid();
}
bool ReactNativeFeatureFlags::enableSpannableBuildingUnification() {
return getAccessor().enableSpannableBuildingUnification();
}
@@ -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<<036e7f3ee4def5b955ed61c707bbc8f8>>
* @generated SignedSource<<a54f29c01ab4dc17de34a0b3ed3a509d>>
*/
/**
@@ -63,6 +63,11 @@ class ReactNativeFeatureFlags {
*/
static bool enableMicrotasks();
/**
* Enables the notification of mount operations to mount hooks on Android.
*/
static bool enableMountHooksAndroid();
/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
@@ -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<<d7a724033028f9edc2b0f9a6714a554d>>
* @generated SignedSource<<f7d54fe8d458d80359a8d6e0e5816b1b>>
*/
/**
@@ -137,6 +137,24 @@ bool ReactNativeFeatureFlagsAccessor::enableMicrotasks() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableMountHooksAndroid() {
auto flagValue = enableMountHooksAndroid_.load();
if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(6, "enableMountHooksAndroid");
flagValue = currentProvider_->enableMountHooksAndroid();
enableMountHooksAndroid_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableSpannableBuildingUnification() {
auto flagValue = enableSpannableBuildingUnification_.load();
@@ -146,7 +164,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSpannableBuildingUnification() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(6, "enableSpannableBuildingUnification");
markFlagAsAccessed(7, "enableSpannableBuildingUnification");
flagValue = currentProvider_->enableSpannableBuildingUnification();
enableSpannableBuildingUnification_ = flagValue;
@@ -164,7 +182,7 @@ bool ReactNativeFeatureFlagsAccessor::inspectorEnableCxxInspectorPackagerConnect
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(7, "inspectorEnableCxxInspectorPackagerConnection");
markFlagAsAccessed(8, "inspectorEnableCxxInspectorPackagerConnection");
flagValue = currentProvider_->inspectorEnableCxxInspectorPackagerConnection();
inspectorEnableCxxInspectorPackagerConnection_ = flagValue;
@@ -182,7 +200,7 @@ bool ReactNativeFeatureFlagsAccessor::inspectorEnableModernCDPRegistry() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(8, "inspectorEnableModernCDPRegistry");
markFlagAsAccessed(9, "inspectorEnableModernCDPRegistry");
flagValue = currentProvider_->inspectorEnableModernCDPRegistry();
inspectorEnableModernCDPRegistry_ = flagValue;
@@ -200,7 +218,7 @@ bool ReactNativeFeatureFlagsAccessor::useModernRuntimeScheduler() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(9, "useModernRuntimeScheduler");
markFlagAsAccessed(10, "useModernRuntimeScheduler");
flagValue = currentProvider_->useModernRuntimeScheduler();
useModernRuntimeScheduler_ = flagValue;
@@ -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<<2fa6a12c1d9b10483d8e2e23125d231e>>
* @generated SignedSource<<d13ffc557c3874e9bdd78558cd309829>>
*/
/**
@@ -37,6 +37,7 @@ class ReactNativeFeatureFlagsAccessor {
bool enableCustomDrawOrderFabric();
bool enableFixForClippedSubviewsCrash();
bool enableMicrotasks();
bool enableMountHooksAndroid();
bool enableSpannableBuildingUnification();
bool inspectorEnableCxxInspectorPackagerConnection();
bool inspectorEnableModernCDPRegistry();
@@ -51,7 +52,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 10> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 11> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> batchRenderingUpdatesInEventLoop_;
@@ -59,6 +60,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableCustomDrawOrderFabric_;
std::atomic<std::optional<bool>> enableFixForClippedSubviewsCrash_;
std::atomic<std::optional<bool>> enableMicrotasks_;
std::atomic<std::optional<bool>> enableMountHooksAndroid_;
std::atomic<std::optional<bool>> enableSpannableBuildingUnification_;
std::atomic<std::optional<bool>> inspectorEnableCxxInspectorPackagerConnection_;
std::atomic<std::optional<bool>> inspectorEnableModernCDPRegistry_;
@@ -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<<927bc1410a5baadf3a4005e50067c4df>>
* @generated SignedSource<<62de1b0e27590ad769296358a4f42c7a>>
*/
/**
@@ -51,6 +51,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool enableMountHooksAndroid() override {
return false;
}
bool enableSpannableBuildingUnification() override {
return false;
}
@@ -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<<74b4ca674d50bda5fb18d74568024399>>
* @generated SignedSource<<3117fc0389416297369a47ee480eb906>>
*/
/**
@@ -31,6 +31,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableCustomDrawOrderFabric() = 0;
virtual bool enableFixForClippedSubviewsCrash() = 0;
virtual bool enableMicrotasks() = 0;
virtual bool enableMountHooksAndroid() = 0;
virtual bool enableSpannableBuildingUnification() = 0;
virtual bool inspectorEnableCxxInspectorPackagerConnection() = 0;
virtual bool inspectorEnableModernCDPRegistry() = 0;
@@ -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<<1a785df8b045c1340d3139bd85add42b>>
* @generated SignedSource<<27923a2dbf1dcbad238a4d06ebb54fb5>>
*/
/**
@@ -67,6 +67,11 @@ bool NativeReactNativeFeatureFlags::enableMicrotasks(
return ReactNativeFeatureFlags::enableMicrotasks();
}
bool NativeReactNativeFeatureFlags::enableMountHooksAndroid(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableMountHooksAndroid();
}
bool NativeReactNativeFeatureFlags::enableSpannableBuildingUnification(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableSpannableBuildingUnification();
@@ -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<<c9ed3da29eba982bc9cbc122e077e04c>>
* @generated SignedSource<<c27f948d57ad70c7db8fd07a78ddd55f>>
*/
/**
@@ -48,6 +48,8 @@ class NativeReactNativeFeatureFlags
bool enableMicrotasks(jsi::Runtime& runtime);
bool enableMountHooksAndroid(jsi::Runtime& runtime);
bool enableSpannableBuildingUnification(jsi::Runtime& runtime);
bool inspectorEnableCxxInspectorPackagerConnection(jsi::Runtime& runtime);
@@ -12,7 +12,6 @@ namespace facebook::react {
bool CoreFeatures::enablePropIteratorSetter = false;
bool CoreFeatures::cacheLastTextMeasurement = false;
bool CoreFeatures::enableGranularScrollViewStateUpdatesIOS = false;
bool CoreFeatures::enableMountHooks = false;
bool CoreFeatures::enableGranularShadowTreeStateReconciliation = false;
bool CoreFeatures::enableClonelessStateProgression = false;
bool CoreFeatures::excludeYogaFromRawProps = false;
@@ -29,9 +29,6 @@ class CoreFeatures {
// updates for all changes in scroll position.
static bool enableGranularScrollViewStateUpdatesIOS;
// Report mount operations from the host platform to notify mount hooks.
static bool enableMountHooks;
// When enabled, the renderer would only fail commits when they propagate
// state and the last commit that updated state changed before committing.
static bool enableGranularShadowTreeStateReconciliation;
@@ -57,6 +57,11 @@ const definitions: FeatureFlagDefinitions = {
description:
'Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).',
},
enableMountHooksAndroid: {
defaultValue: false,
description:
'Enables the notification of mount operations to mount hooks on Android.',
},
enableSpannableBuildingUnification: {
defaultValue: false,
description:
@@ -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<<fd6c4691a532a520ba08ef0ed2ae297c>>
* @generated SignedSource<<fcbf05836bd9465c6a035669f6fc78f4>>
* @flow strict-local
*/
@@ -29,6 +29,7 @@ export interface Spec extends TurboModule {
+enableCustomDrawOrderFabric?: () => boolean;
+enableFixForClippedSubviewsCrash?: () => boolean;
+enableMicrotasks?: () => boolean;
+enableMountHooksAndroid?: () => boolean;
+enableSpannableBuildingUnification?: () => boolean;
+inspectorEnableCxxInspectorPackagerConnection?: () => boolean;
+inspectorEnableModernCDPRegistry?: () => boolean;
@@ -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<<c055b3ee44111eb5e3367c664befc685>>
* @generated SignedSource<<aade6c478e09fb1f92319c3f46adaf13>>
* @flow strict-local
*/
@@ -46,6 +46,7 @@ export type ReactNativeFeatureFlags = {
enableCustomDrawOrderFabric: Getter<boolean>,
enableFixForClippedSubviewsCrash: Getter<boolean>,
enableMicrotasks: Getter<boolean>,
enableMountHooksAndroid: Getter<boolean>,
enableSpannableBuildingUnification: Getter<boolean>,
inspectorEnableCxxInspectorPackagerConnection: Getter<boolean>,
inspectorEnableModernCDPRegistry: Getter<boolean>,
@@ -116,6 +117,10 @@ export const enableFixForClippedSubviewsCrash: Getter<boolean> = createNativeFla
* Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).
*/
export const enableMicrotasks: Getter<boolean> = createNativeFlagGetter('enableMicrotasks', false);
/**
* Enables the notification of mount operations to mount hooks on Android.
*/
export const enableMountHooksAndroid: Getter<boolean> = createNativeFlagGetter('enableMountHooksAndroid', false);
/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/