diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index 96f0ef3bf8b..b2fb68f5d37 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt @@ -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<> + * @generated SignedSource<<3e4d74a17c15742d35db9e4247f3e1c1>> */ /** @@ -316,7 +316,7 @@ public object ReactNativeFeatureFlags { * Enables a new mechanism in ShadowTree to prevent problems caused by multiple threads trying to commit concurrently. If a thread tries to commit a few times unsuccessfully, it will acquire a lock and try again. */ @JvmStatic - public fun preventShadowTreeCommitExhaustionWithLocking(): Boolean = accessor.preventShadowTreeCommitExhaustionWithLocking() + public fun preventShadowTreeCommitExhaustion(): Boolean = accessor.preventShadowTreeCommitExhaustion() /** * Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt index 4a965f52687..9edc477ef4f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt @@ -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<<773ddcede573164ba82db671341ddc3f>> + * @generated SignedSource<> */ /** @@ -67,7 +67,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var fuseboxNetworkInspectionEnabledCache: Boolean? = null private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null private var preparedTextCacheSizeCache: Double? = null - private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null + private var preventShadowTreeCommitExhaustionCache: Boolean? = null private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null @@ -503,11 +503,11 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } - override fun preventShadowTreeCommitExhaustionWithLocking(): Boolean { - var cached = preventShadowTreeCommitExhaustionWithLockingCache + override fun preventShadowTreeCommitExhaustion(): Boolean { + var cached = preventShadowTreeCommitExhaustionCache if (cached == null) { - cached = ReactNativeFeatureFlagsCxxInterop.preventShadowTreeCommitExhaustionWithLocking() - preventShadowTreeCommitExhaustionWithLockingCache = cached + cached = ReactNativeFeatureFlagsCxxInterop.preventShadowTreeCommitExhaustion() + preventShadowTreeCommitExhaustionCache = cached } return cached } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt index ac7ba42df0c..afd221a4bf2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt @@ -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<<96fca46813d841eb7f4d043010513999>> + * @generated SignedSource<> */ /** @@ -122,7 +122,7 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun preparedTextCacheSize(): Double - @DoNotStrip @JvmStatic public external fun preventShadowTreeCommitExhaustionWithLocking(): Boolean + @DoNotStrip @JvmStatic public external fun preventShadowTreeCommitExhaustion(): Boolean @DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt index 7a559e2b388..e59da172aba 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -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<<8ebd61411e0e0ac8c8b307cf803f1206>> + * @generated SignedSource<<12c2727291b635ef7c3163d153669c2c>> */ /** @@ -117,7 +117,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun preparedTextCacheSize(): Double = 200.0 - override fun preventShadowTreeCommitExhaustionWithLocking(): Boolean = false + override fun preventShadowTreeCommitExhaustion(): Boolean = false override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt index 3469d3ab04b..baa7b54af77 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt @@ -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<> + * @generated SignedSource<<3ea9946ef21c8ac8bb9bb63712636e89>> */ /** @@ -71,7 +71,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var fuseboxNetworkInspectionEnabledCache: Boolean? = null private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null private var preparedTextCacheSizeCache: Double? = null - private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null + private var preventShadowTreeCommitExhaustionCache: Boolean? = null private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null @@ -554,12 +554,12 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } - override fun preventShadowTreeCommitExhaustionWithLocking(): Boolean { - var cached = preventShadowTreeCommitExhaustionWithLockingCache + override fun preventShadowTreeCommitExhaustion(): Boolean { + var cached = preventShadowTreeCommitExhaustionCache if (cached == null) { - cached = currentProvider.preventShadowTreeCommitExhaustionWithLocking() - accessedFeatureFlags.add("preventShadowTreeCommitExhaustionWithLocking") - preventShadowTreeCommitExhaustionWithLockingCache = cached + cached = currentProvider.preventShadowTreeCommitExhaustion() + accessedFeatureFlags.add("preventShadowTreeCommitExhaustion") + preventShadowTreeCommitExhaustionCache = cached } return cached } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt index ecacb9c45ef..2d32fcd900e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt @@ -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<<93aab733661b558c1701b728c18b3d00>> + * @generated SignedSource<<58da46268043f086730132430735b720>> */ /** @@ -23,5 +23,5 @@ public open class ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android : // We could use JNI to get the defaults from C++, // but that is more expensive than just duplicating the defaults here. - override fun preventShadowTreeCommitExhaustionWithLocking(): Boolean = true + override fun preventShadowTreeCommitExhaustion(): Boolean = true } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt index c18b292a933..1da19692aed 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt @@ -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<> + * @generated SignedSource<<1e81de36735c6c9286b228c75c9a0228>> */ /** @@ -117,7 +117,7 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun preparedTextCacheSize(): Double - @DoNotStrip public fun preventShadowTreeCommitExhaustionWithLocking(): Boolean + @DoNotStrip public fun preventShadowTreeCommitExhaustion(): Boolean @DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp index 5e812f4a5d8..0bcbbc10fc9 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp @@ -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<<7fac1c2c0c3ce131442319925e4231dc>> + * @generated SignedSource<> */ /** @@ -321,9 +321,9 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } - bool preventShadowTreeCommitExhaustionWithLocking() override { + bool preventShadowTreeCommitExhaustion() override { static const auto method = - getReactNativeFeatureFlagsProviderJavaClass()->getMethod("preventShadowTreeCommitExhaustionWithLocking"); + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("preventShadowTreeCommitExhaustion"); return method(javaProvider_); } @@ -632,9 +632,9 @@ double JReactNativeFeatureFlagsCxxInterop::preparedTextCacheSize( return ReactNativeFeatureFlags::preparedTextCacheSize(); } -bool JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustionWithLocking( +bool JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustion( facebook::jni::alias_ref /*unused*/) { - return ReactNativeFeatureFlags::preventShadowTreeCommitExhaustionWithLocking(); + return ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion(); } bool JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid( @@ -865,8 +865,8 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { "preparedTextCacheSize", JReactNativeFeatureFlagsCxxInterop::preparedTextCacheSize), makeNativeMethod( - "preventShadowTreeCommitExhaustionWithLocking", - JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustionWithLocking), + "preventShadowTreeCommitExhaustion", + JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustion), makeNativeMethod( "traceTurboModulePromiseRejectionsOnAndroid", JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h index a384a3b0006..42312d4bf22 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h @@ -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<<07daae0284829d56b7eaa330b1973e02>> + * @generated SignedSource<> */ /** @@ -171,7 +171,7 @@ class JReactNativeFeatureFlagsCxxInterop static double preparedTextCacheSize( facebook::jni::alias_ref); - static bool preventShadowTreeCommitExhaustionWithLocking( + static bool preventShadowTreeCommitExhaustion( facebook::jni::alias_ref); static bool traceTurboModulePromiseRejectionsOnAndroid( diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 262c68e63be..1feef568183 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -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<<0179ba45718903d6fec6dcc19b0e1aaa>> + * @generated SignedSource<> */ /** @@ -214,8 +214,8 @@ double ReactNativeFeatureFlags::preparedTextCacheSize() { return getAccessor().preparedTextCacheSize(); } -bool ReactNativeFeatureFlags::preventShadowTreeCommitExhaustionWithLocking() { - return getAccessor().preventShadowTreeCommitExhaustionWithLocking(); +bool ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion() { + return getAccessor().preventShadowTreeCommitExhaustion(); } bool ReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid() { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index df585d8c6e2..6663518acd8 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -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<<5055890d2cb2fb46a940f8308f014f0b>> + * @generated SignedSource<> */ /** @@ -277,7 +277,7 @@ class ReactNativeFeatureFlags { /** * Enables a new mechanism in ShadowTree to prevent problems caused by multiple threads trying to commit concurrently. If a thread tries to commit a few times unsuccessfully, it will acquire a lock and try again. */ - RN_EXPORT static bool preventShadowTreeCommitExhaustionWithLocking(); + RN_EXPORT static bool preventShadowTreeCommitExhaustion(); /** * Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause. diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index fc18530eaa6..877131981d2 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -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<> + * @generated SignedSource<<681bff71eb87886a108f67b3162b030c>> */ /** @@ -875,8 +875,8 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() { return flagValue.value(); } -bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustionWithLocking() { - auto flagValue = preventShadowTreeCommitExhaustionWithLocking_.load(); +bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() { + auto flagValue = preventShadowTreeCommitExhaustion_.load(); if (!flagValue.has_value()) { // This block is not exclusive but it is not necessary. @@ -884,10 +884,10 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustionWithLocki // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(47, "preventShadowTreeCommitExhaustionWithLocking"); + markFlagAsAccessed(47, "preventShadowTreeCommitExhaustion"); - flagValue = currentProvider_->preventShadowTreeCommitExhaustionWithLocking(); - preventShadowTreeCommitExhaustionWithLocking_ = flagValue; + flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); + preventShadowTreeCommitExhaustion_ = flagValue; } return flagValue.value(); diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 86dc5b3d7ea..c71e8133664 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -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<<5ed90d5ed1a03a16f551cd1cf6cbdeb3>> + * @generated SignedSource<> */ /** @@ -79,7 +79,7 @@ class ReactNativeFeatureFlagsAccessor { bool fuseboxNetworkInspectionEnabled(); bool hideOffscreenVirtualViewsOnIOS(); double preparedTextCacheSize(); - bool preventShadowTreeCommitExhaustionWithLocking(); + bool preventShadowTreeCommitExhaustion(); bool traceTurboModulePromiseRejectionsOnAndroid(); bool updateRuntimeShadowNodeReferencesOnCommit(); bool useAlwaysAvailableJSErrorHandling(); @@ -151,7 +151,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> fuseboxNetworkInspectionEnabled_; std::atomic> hideOffscreenVirtualViewsOnIOS_; std::atomic> preparedTextCacheSize_; - std::atomic> preventShadowTreeCommitExhaustionWithLocking_; + std::atomic> preventShadowTreeCommitExhaustion_; std::atomic> traceTurboModulePromiseRejectionsOnAndroid_; std::atomic> updateRuntimeShadowNodeReferencesOnCommit_; std::atomic> useAlwaysAvailableJSErrorHandling_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 57cd86951e5..0dc1de80ced 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -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<> + * @generated SignedSource<<9832c18e4c7ccf232b7222e2356f99d9>> */ /** @@ -215,7 +215,7 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return 200.0; } - bool preventShadowTreeCommitExhaustionWithLocking() override { + bool preventShadowTreeCommitExhaustion() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index f283d6d641b..46ec128d23b 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -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<> + * @generated SignedSource<<19f0a48bcfa8f8ffaf634e85301adc7e>> */ /** @@ -468,13 +468,13 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::preparedTextCacheSize(); } - bool preventShadowTreeCommitExhaustionWithLocking() override { - auto value = values_["preventShadowTreeCommitExhaustionWithLocking"]; + bool preventShadowTreeCommitExhaustion() override { + auto value = values_["preventShadowTreeCommitExhaustion"]; if (!value.isNull()) { return value.getBool(); } - return ReactNativeFeatureFlagsDefaults::preventShadowTreeCommitExhaustionWithLocking(); + return ReactNativeFeatureFlagsDefaults::preventShadowTreeCommitExhaustion(); } bool traceTurboModulePromiseRejectionsOnAndroid() override { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h index a9e9a58c800..c45e55ce07a 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h @@ -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<<16c5fdf431579bbfd454a28c06f28c41>> + * @generated SignedSource<> */ /** @@ -27,7 +27,7 @@ class ReactNativeFeatureFlagsOverridesOSSExperimental : public ReactNativeFeatur public: ReactNativeFeatureFlagsOverridesOSSExperimental() = default; - bool preventShadowTreeCommitExhaustionWithLocking() override { + bool preventShadowTreeCommitExhaustion() override { return true; } }; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index ac2506e700f..3df0f3be4a1 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -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<> + * @generated SignedSource<<815769cc8d08e19b2598dd1862ed5060>> */ /** @@ -72,7 +72,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool fuseboxNetworkInspectionEnabled() = 0; virtual bool hideOffscreenVirtualViewsOnIOS() = 0; virtual double preparedTextCacheSize() = 0; - virtual bool preventShadowTreeCommitExhaustionWithLocking() = 0; + virtual bool preventShadowTreeCommitExhaustion() = 0; virtual bool traceTurboModulePromiseRejectionsOnAndroid() = 0; virtual bool updateRuntimeShadowNodeReferencesOnCommit() = 0; virtual bool useAlwaysAvailableJSErrorHandling() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index f05433332df..cda934866a5 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -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<> + * @generated SignedSource<<474a64af739969acebb4bb9bb1005168>> */ /** @@ -279,9 +279,9 @@ double NativeReactNativeFeatureFlags::preparedTextCacheSize( return ReactNativeFeatureFlags::preparedTextCacheSize(); } -bool NativeReactNativeFeatureFlags::preventShadowTreeCommitExhaustionWithLocking( +bool NativeReactNativeFeatureFlags::preventShadowTreeCommitExhaustion( jsi::Runtime& /*runtime*/) { - return ReactNativeFeatureFlags::preventShadowTreeCommitExhaustionWithLocking(); + return ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion(); } bool NativeReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid( diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index eb4e64ad071..5696d5a7c7f 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -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<<03ab35c55476b69046e67235b66533a0>> + * @generated SignedSource<> */ /** @@ -130,7 +130,7 @@ class NativeReactNativeFeatureFlags double preparedTextCacheSize(jsi::Runtime& runtime); - bool preventShadowTreeCommitExhaustionWithLocking(jsi::Runtime& runtime); + bool preventShadowTreeCommitExhaustion(jsi::Runtime& runtime); bool traceTurboModulePromiseRejectionsOnAndroid(jsi::Runtime& runtime); diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp index c803f80e027..483a1915fd6 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -22,12 +22,12 @@ namespace facebook::react { -using CommitStatus = ShadowTree::CommitStatus; -using CommitMode = ShadowTree::CommitMode; - namespace { const int MAX_COMMIT_ATTEMPTS_BEFORE_LOCKING = 3; -} +} // namespace + +using CommitStatus = ShadowTree::CommitStatus; +using CommitMode = ShadowTree::CommitMode; /* * Generates (possibly) a new tree where all nodes with non-obsolete `State` @@ -214,7 +214,8 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const { auto revision = ShadowTreeRevision{}; { - std::unique_lock lock(commitMutex_); + ShadowTree::UniqueLock lock = uniqueCommitLock(); + if (commitMode_ == commitMode) { return; } @@ -231,7 +232,7 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const { } CommitMode ShadowTree::getCommitMode() const { - std::shared_lock lock(commitMutex_); + SharedLock lock = sharedCommitLock(); return commitMode_; } @@ -245,7 +246,7 @@ CommitStatus ShadowTree::commit( const CommitOptions& commitOptions) const { [[maybe_unused]] int attempts = 0; - if (ReactNativeFeatureFlags::preventShadowTreeCommitExhaustionWithLocking()) { + if (ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion()) { while (attempts < MAX_COMMIT_ATTEMPTS_BEFORE_LOCKING) { auto status = tryCommit(transaction, commitOptions); if (status != CommitStatus::Failed) { @@ -255,8 +256,8 @@ CommitStatus ShadowTree::commit( } { - std::unique_lock lock(commitMutex_); - return tryCommit(transaction, commitOptions, true); + std::unique_lock lock(commitMutexRecursive_); + return tryCommit(transaction, commitOptions); } } else { while (true) { @@ -276,8 +277,7 @@ CommitStatus ShadowTree::commit( CommitStatus ShadowTree::tryCommit( const ShadowTreeCommitTransaction& transaction, - const CommitOptions& commitOptions, - bool hasLocked) const { + const CommitOptions& commitOptions) const { TraceSection s("ShadowTree::commit"); auto telemetry = TransactionTelemetry{}; @@ -289,10 +289,7 @@ CommitStatus ShadowTree::tryCommit( { // Reading `currentRevision_` in shared manner. - std::shared_lock lock(commitMutex_, std::defer_lock); - if (!hasLocked) { - lock.lock(); - } + SharedLock lock = sharedCommitLock(); commitMode = commitMode_; oldRevision = currentRevision_; } @@ -333,10 +330,7 @@ CommitStatus ShadowTree::tryCommit( { // Updating `currentRevision_` in unique manner if it hasn't changed. - std::unique_lock lock(commitMutex_, std::defer_lock); - if (!hasLocked) { - lock.lock(); - } + UniqueLock lock = uniqueCommitLock(); if (currentRevision_.number != oldRevision.number) { return CommitStatus::Failed; @@ -375,7 +369,7 @@ CommitStatus ShadowTree::tryCommit( } ShadowTreeRevision ShadowTree::getCurrentRevision() const { - std::shared_lock lock(commitMutex_); + SharedLock lock = sharedCommitLock(); return currentRevision_; } @@ -423,4 +417,20 @@ void ShadowTree::notifyDelegatesOfUpdates() const { delegate_.shadowTreeDidFinishTransaction(mountingCoordinator_, true); } +inline ShadowTree::UniqueLock ShadowTree::uniqueCommitLock() const { + if (ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion()) { + return std::unique_lock{commitMutexRecursive_}; + } else { + return std::unique_lock{commitMutex_}; + } +} + +inline ShadowTree::SharedLock ShadowTree::sharedCommitLock() const { + if (ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion()) { + return std::unique_lock{commitMutexRecursive_}; + } else { + return std::shared_lock{commitMutex_}; + } +} + } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h index 6824ae9389c..33e10e102a8 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -8,6 +8,8 @@ #pragma once #include +#include +#include #include #include @@ -111,8 +113,7 @@ class ShadowTree final { */ CommitStatus tryCommit( const ShadowTreeCommitTransaction& transaction, - const CommitOptions& commitOptions, - bool hasLocked = false) const; + const CommitOptions& commitOptions) const; /* * Calls `tryCommit` in a loop until it finishes successfully. @@ -151,10 +152,21 @@ class ShadowTree final { const SurfaceId surfaceId_; const ShadowTreeDelegate& delegate_; mutable std::shared_mutex commitMutex_; + mutable std::recursive_mutex commitMutexRecursive_; mutable CommitMode commitMode_{ CommitMode::Normal}; // Protected by `commitMutex_`. mutable ShadowTreeRevision currentRevision_; // Protected by `commitMutex_`. std::shared_ptr mountingCoordinator_; + + using UniqueLock = std::variant< + std::unique_lock, + std::unique_lock>; + using SharedLock = std::variant< + std::shared_lock, + std::unique_lock>; + + inline UniqueLock uniqueCommitLock() const; + inline SharedLock sharedCommitLock() const; }; } // namespace facebook::react diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index def532446ec..7bb81fa3bf0 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -543,10 +543,10 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - preventShadowTreeCommitExhaustionWithLocking: { + preventShadowTreeCommitExhaustion: { defaultValue: false, metadata: { - dateAdded: '2025-07-14', + dateAdded: '2025-07-23', description: 'Enables a new mechanism in ShadowTree to prevent problems caused by multiple threads trying to commit concurrently. If a thread tries to commit a few times unsuccessfully, it will acquire a lock and try again.', expectedReleaseValue: true, diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 5bd2bea3215..ee5043e87bc 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -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<<595a51e39658c12aab12032f7b928615>> + * @generated SignedSource<<999a8d329cdab258ac64c03b24f1a516>> * @flow strict * @noformat */ @@ -98,7 +98,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{ fuseboxNetworkInspectionEnabled: Getter, hideOffscreenVirtualViewsOnIOS: Getter, preparedTextCacheSize: Getter, - preventShadowTreeCommitExhaustionWithLocking: Getter, + preventShadowTreeCommitExhaustion: Getter, traceTurboModulePromiseRejectionsOnAndroid: Getter, updateRuntimeShadowNodeReferencesOnCommit: Getter, useAlwaysAvailableJSErrorHandling: Getter, @@ -387,7 +387,7 @@ export const preparedTextCacheSize: Getter = createNativeFlagGetter('pre /** * Enables a new mechanism in ShadowTree to prevent problems caused by multiple threads trying to commit concurrently. If a thread tries to commit a few times unsuccessfully, it will acquire a lock and try again. */ -export const preventShadowTreeCommitExhaustionWithLocking: Getter = createNativeFlagGetter('preventShadowTreeCommitExhaustionWithLocking', false); +export const preventShadowTreeCommitExhaustion: Getter = createNativeFlagGetter('preventShadowTreeCommitExhaustion', false); /** * Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 600adf6f8d4..e64f0920b3e 100644 --- a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js @@ -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<<9d6574da819c190bed0458559c66a089>> + * @generated SignedSource<<1b84b6e04c214f6c2798010372937990>> * @flow strict * @noformat */ @@ -72,7 +72,7 @@ export interface Spec extends TurboModule { +fuseboxNetworkInspectionEnabled?: () => boolean; +hideOffscreenVirtualViewsOnIOS?: () => boolean; +preparedTextCacheSize?: () => number; - +preventShadowTreeCommitExhaustionWithLocking?: () => boolean; + +preventShadowTreeCommitExhaustion?: () => boolean; +traceTurboModulePromiseRejectionsOnAndroid?: () => boolean; +updateRuntimeShadowNodeReferencesOnCommit?: () => boolean; +useAlwaysAvailableJSErrorHandling?: () => boolean;