Clean up feature flag for mount hooks on Android (#44206)

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

Changelog: [internal]

We finally managed to implement mount hooks without reliability issues on Android, so we can clean up the feature flag and enable it unconditionally.

Reviewed By: cortinico

Differential Revision: D56467379

fbshipit-source-id: d797ec770b731135332bc9f39df1c1e684b3bde4
This commit is contained in:
Rubén Norte
2024-04-23 08:48:06 -07:00
committed by Facebook GitHub Bot
parent 0a80270187
commit ff094d80d0
20 changed files with 30 additions and 134 deletions
@@ -1233,9 +1233,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener, UIBlo
listener.didMountItems(FabricUIManager.this);
}
if (!ReactNativeFeatureFlags.enableMountHooksAndroid()
|| mountItems == null
|| mountItems.isEmpty()) {
if (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<<61b929b9624eeaedfa12d2f390299447>>
* @generated SignedSource<<8915b173bf7bc423cff555366f522615>>
*/
/**
@@ -64,12 +64,6 @@ 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<<46e1a8dd088d588ea9eec703d7155710>>
* @generated SignedSource<<f7e306b346e95ea68be34c7d7708c316>>
*/
/**
@@ -26,7 +26,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var enableSynchronousStateUpdatesCache: Boolean? = null
private var enableUIConsistencyCache: Boolean? = null
@@ -92,15 +91,6 @@ 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<<56ac4a5eaf65775fdb757fc10ed82908>>
* @generated SignedSource<<43d74c7b95ae537455e1aafe7daeb397>>
*/
/**
@@ -40,8 +40,6 @@ 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 enableSynchronousStateUpdates(): 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<<6cc4fccd13a1e426a2d6a2a24530e5e6>>
* @generated SignedSource<<c6c02b3249add27dd868af02151235aa>>
*/
/**
@@ -35,8 +35,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableMicrotasks(): Boolean = false
override fun enableMountHooksAndroid(): Boolean = false
override fun enableSpannableBuildingUnification(): Boolean = false
override fun enableSynchronousStateUpdates(): 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<<c1c7546acade83cf63f3c06e78352982>>
* @generated SignedSource<<919173dae59866dbd93ccbfa3a7f9118>>
*/
/**
@@ -30,7 +30,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var enableSynchronousStateUpdatesCache: Boolean? = null
private var enableUIConsistencyCache: Boolean? = null
@@ -102,16 +101,6 @@ 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<<a5cbe59693a5f7d64af6e004951ab971>>
* @generated SignedSource<<a022c7f29ebb4b7351253a32efe6203a>>
*/
/**
@@ -35,8 +35,6 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableMicrotasks(): Boolean
@DoNotStrip public fun enableMountHooksAndroid(): Boolean
@DoNotStrip public fun enableSpannableBuildingUnification(): Boolean
@DoNotStrip public fun enableSynchronousStateUpdates(): 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<<f8ac6f7e857808ade5d0f26ec7924604>>
* @generated SignedSource<<63bb565e7ab5a1e16ce5f9a7d0b93303>>
*/
/**
@@ -75,12 +75,6 @@ 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");
@@ -175,11 +169,6 @@ 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();
@@ -265,9 +254,6 @@ 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<<a6b8839cf6f9e87848289a8c5c37a5c8>>
* @generated SignedSource<<c676d8771641013158d8b07a19ba556b>>
*/
/**
@@ -48,9 +48,6 @@ 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<<0fe73e0526dbc2f860029b8cb0fbcfe3>>
* @generated SignedSource<<e0775f2263b3a9dd8e69dde74557ba2a>>
*/
/**
@@ -45,10 +45,6 @@ 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<<d6a33b997461fd186c58a956f6854aca>>
* @generated SignedSource<<89f6dda7de10b5dab880ffc2908248f6>>
*/
/**
@@ -67,11 +67,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableMicrotasks();
/**
* Enables the notification of mount operations to mount hooks on Android.
*/
RN_EXPORT 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<<f77452d93caa28c074c6ba8595572e6c>>
* @generated SignedSource<<faf050dbfb7102fc9f057e548aec6793>>
*/
/**
@@ -137,24 +137,6 @@ 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();
@@ -164,7 +146,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(7, "enableSpannableBuildingUnification");
markFlagAsAccessed(6, "enableSpannableBuildingUnification");
flagValue = currentProvider_->enableSpannableBuildingUnification();
enableSpannableBuildingUnification_ = flagValue;
@@ -182,7 +164,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSynchronousStateUpdates() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(8, "enableSynchronousStateUpdates");
markFlagAsAccessed(7, "enableSynchronousStateUpdates");
flagValue = currentProvider_->enableSynchronousStateUpdates();
enableSynchronousStateUpdates_ = flagValue;
@@ -200,7 +182,7 @@ bool ReactNativeFeatureFlagsAccessor::enableUIConsistency() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(9, "enableUIConsistency");
markFlagAsAccessed(8, "enableUIConsistency");
flagValue = currentProvider_->enableUIConsistency();
enableUIConsistency_ = flagValue;
@@ -218,7 +200,7 @@ bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(10, "forceBatchingMountItemsOnAndroid");
markFlagAsAccessed(9, "forceBatchingMountItemsOnAndroid");
flagValue = currentProvider_->forceBatchingMountItemsOnAndroid();
forceBatchingMountItemsOnAndroid_ = flagValue;
@@ -236,7 +218,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(11, "inspectorEnableCxxInspectorPackagerConnection");
markFlagAsAccessed(10, "inspectorEnableCxxInspectorPackagerConnection");
flagValue = currentProvider_->inspectorEnableCxxInspectorPackagerConnection();
inspectorEnableCxxInspectorPackagerConnection_ = flagValue;
@@ -254,7 +236,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(12, "inspectorEnableModernCDPRegistry");
markFlagAsAccessed(11, "inspectorEnableModernCDPRegistry");
flagValue = currentProvider_->inspectorEnableModernCDPRegistry();
inspectorEnableModernCDPRegistry_ = flagValue;
@@ -272,7 +254,7 @@ bool ReactNativeFeatureFlagsAccessor::preventDoubleTextMeasure() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(13, "preventDoubleTextMeasure");
markFlagAsAccessed(12, "preventDoubleTextMeasure");
flagValue = currentProvider_->preventDoubleTextMeasure();
preventDoubleTextMeasure_ = flagValue;
@@ -290,7 +272,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(14, "useModernRuntimeScheduler");
markFlagAsAccessed(13, "useModernRuntimeScheduler");
flagValue = currentProvider_->useModernRuntimeScheduler();
useModernRuntimeScheduler_ = flagValue;
@@ -308,7 +290,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(15, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(14, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -326,7 +308,7 @@ bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(16, "useStateAlignmentMechanism");
markFlagAsAccessed(15, "useStateAlignmentMechanism");
flagValue = currentProvider_->useStateAlignmentMechanism();
useStateAlignmentMechanism_ = 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<<2ac50c51832dfbcebfc8875c02738727>>
* @generated SignedSource<<7ec1c929562737037ff524a042bbcf54>>
*/
/**
@@ -37,7 +37,6 @@ class ReactNativeFeatureFlagsAccessor {
bool enableCleanTextInputYogaNode();
bool enableCustomDrawOrderFabric();
bool enableMicrotasks();
bool enableMountHooksAndroid();
bool enableSpannableBuildingUnification();
bool enableSynchronousStateUpdates();
bool enableUIConsistency();
@@ -58,7 +57,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 17> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 16> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> batchRenderingUpdatesInEventLoop_;
@@ -66,7 +65,6 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableCleanTextInputYogaNode_;
std::atomic<std::optional<bool>> enableCustomDrawOrderFabric_;
std::atomic<std::optional<bool>> enableMicrotasks_;
std::atomic<std::optional<bool>> enableMountHooksAndroid_;
std::atomic<std::optional<bool>> enableSpannableBuildingUnification_;
std::atomic<std::optional<bool>> enableSynchronousStateUpdates_;
std::atomic<std::optional<bool>> enableUIConsistency_;
@@ -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<<b638a8d33a5b542e93b1bfa784ff500d>>
* @generated SignedSource<<a4f3d7d441089e7f8f95c19c463c038d>>
*/
/**
@@ -51,10 +51,6 @@ 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<<2ffedc198d97593ae8c5d5300aa640a2>>
* @generated SignedSource<<c488fb453099ed668382fb8cf8af962f>>
*/
/**
@@ -31,7 +31,6 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableCleanTextInputYogaNode() = 0;
virtual bool enableCustomDrawOrderFabric() = 0;
virtual bool enableMicrotasks() = 0;
virtual bool enableMountHooksAndroid() = 0;
virtual bool enableSpannableBuildingUnification() = 0;
virtual bool enableSynchronousStateUpdates() = 0;
virtual bool enableUIConsistency() = 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<<a24c9972eebff849abd9b0e7ef4ff525>>
* @generated SignedSource<<f32cab91b22bccace4e23b996ef1609c>>
*/
/**
@@ -67,11 +67,6 @@ 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<<92830e364788db00fd06d4e152ef7727>>
* @generated SignedSource<<5d7f748ee93a70ac0bfe378e892c1051>>
*/
/**
@@ -47,8 +47,6 @@ class NativeReactNativeFeatureFlags
bool enableMicrotasks(jsi::Runtime& runtime);
bool enableMountHooksAndroid(jsi::Runtime& runtime);
bool enableSpannableBuildingUnification(jsi::Runtime& runtime);
bool enableSynchronousStateUpdates(jsi::Runtime& runtime);
@@ -56,11 +56,6 @@ 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<<0e0858557eb27f3eebfecae18ee13c0b>>
* @generated SignedSource<<62830c2a4eb13efee6abea1822f4cf1c>>
* @flow strict-local
*/
@@ -46,7 +46,6 @@ export type ReactNativeFeatureFlags = {
enableCleanTextInputYogaNode: Getter<boolean>,
enableCustomDrawOrderFabric: Getter<boolean>,
enableMicrotasks: Getter<boolean>,
enableMountHooksAndroid: Getter<boolean>,
enableSpannableBuildingUnification: Getter<boolean>,
enableSynchronousStateUpdates: Getter<boolean>,
enableUIConsistency: Getter<boolean>,
@@ -123,10 +122,6 @@ export const enableCustomDrawOrderFabric: Getter<boolean> = createNativeFlagGett
* 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
*/
@@ -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<<4ba909c3b360c6a4fc9c6ed5996b6a13>>
* @generated SignedSource<<2db7341f650d61fce96356d75231f44a>>
* @flow strict-local
*/
@@ -29,7 +29,6 @@ export interface Spec extends TurboModule {
+enableCleanTextInputYogaNode?: () => boolean;
+enableCustomDrawOrderFabric?: () => boolean;
+enableMicrotasks?: () => boolean;
+enableMountHooksAndroid?: () => boolean;
+enableSpannableBuildingUnification?: () => boolean;
+enableSynchronousStateUpdates?: () => boolean;
+enableUIConsistency?: () => boolean;