diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt index 984aa3e1206..b43cdbd20ed 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt @@ -55,7 +55,6 @@ import com.facebook.systrace.Systrace import java.util.ArrayDeque import java.util.LinkedList import java.util.Queue -import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.Volatile import kotlin.concurrent.read @@ -87,20 +86,9 @@ internal constructor( public var context: ThemedReactContext? = reactContext private set - private val tagToViewState: ConcurrentHashMap? - private val optimizedTagToViewState: MutableIntObjectMap? + private val tagToViewState: MutableIntObjectMap = MutableIntObjectMap() private val registryLock = ReentrantReadWriteLock() - init { - if (ReactNativeFeatureFlags.useOptimizedViewRegistryOnAndroid()) { - tagToViewState = null - optimizedTagToViewState = MutableIntObjectMap() - } else { - tagToViewState = ConcurrentHashMap() - optimizedTagToViewState = null - } - } - private val onViewAttachMountItems: Queue = ArrayDeque() // These are all non-null, until StopSurface is called @@ -142,7 +130,9 @@ internal constructor( return } - registryPut(surfaceId, ViewState(surfaceId, rootView, rootViewManager, true)) + registryLock.write { + tagToViewState[surfaceId] = ViewState(surfaceId, rootView, rootViewManager, true) + } val runnable: Runnable = object : GuardedRunnable(checkNotNull(context)) { @@ -206,7 +196,7 @@ internal constructor( if (tagSetForStoppedSurface?.containsKey(tag) == true) { return true } - return registryContains(tag) + return registryLock.read { tagToViewState.containsKey(tag) } } @UiThread @@ -252,12 +242,14 @@ internal constructor( // Reset all StateWrapper objects // Since this can happen on any thread, is it possible to race between StateWrapper destruction // and some accesses from View classes in the UI thread? - registryForEachValue { viewState -> - viewState.stateWrapper?.destroyState() - viewState.stateWrapper = null + registryLock.read { + tagToViewState.forEachValue { viewState -> + viewState.stateWrapper?.destroyState() + viewState.stateWrapper = null - viewState.eventEmitter?.destroy() - viewState.eventEmitter = null + viewState.eventEmitter?.destroy() + viewState.eventEmitter = null + } } val runnable = Runnable { @@ -265,29 +257,23 @@ internal constructor( viewManagerRegistry?.onSurfaceStopped(surfaceId) } - if (optimizedTagToViewState != null) { - val viewStatesToDelete: ArrayList - registryLock.write { - val tagSetForStoppedSurface = - SparseArrayCompat().also { this.tagSetForStoppedSurface = it } - viewStatesToDelete = ArrayList(optimizedTagToViewState.size) - optimizedTagToViewState.forEach { key, value -> - tagSetForStoppedSurface[key] = this@SurfaceMountingManager - viewStatesToDelete.add(value) - } - optimizedTagToViewState.clear() + // Using this as a placeholder value in the map. We're using SparseArrayCompat + // since it can efficiently represent the list of pending tags + val tagSetForStoppedSurface = + SparseArrayCompat().also { this.tagSetForStoppedSurface = it } + + val viewStatesToDelete: ArrayList + registryLock.write { + viewStatesToDelete = ArrayList(tagToViewState.size) + tagToViewState.forEach { key, value -> + tagSetForStoppedSurface[key] = this@SurfaceMountingManager + viewStatesToDelete.add(value) } - for (viewState in viewStatesToDelete) { - onViewStateDeleted(viewState) - } - } else { - val tagSetForStoppedSurface = - SparseArrayCompat().also { this.tagSetForStoppedSurface = it } - for ((key, value) in tagToViewState!!) { - tagSetForStoppedSurface[key] = this - onViewStateDeleted(value) - } - tagToViewState!!.clear() + tagToViewState.clear() + } + for (viewState in viewStatesToDelete) { + // We must call `onDropViewInstance` on all remaining Views + onViewStateDeleted(viewState) } // Evict all views from cache and memory @@ -602,7 +588,7 @@ internal constructor( this.stateWrapper = stateWrapper this.eventEmitter = eventEmitterWrapper } - registryPut(reactTag, viewState) + registryLock.write { tagToViewState[reactTag] = viewState } if (isLayoutable) { @Suppress("UNCHECKED_CAST") @@ -977,17 +963,9 @@ internal constructor( // TODO T62717437 - Use a flag to determine that these event emitters belong to virtual nodes // only. - val viewState: ViewState = - if (optimizedTagToViewState != null) { - registryLock.write { optimizedTagToViewState.getOrPut(reactTag) { ViewState(reactTag) } } - } else { - var vs = tagToViewState!![reactTag] - if (vs == null) { - vs = ViewState(reactTag) - tagToViewState!![reactTag] = vs - } - vs - } + val viewState: ViewState = registryLock.write { + tagToViewState.getOrPut(reactTag) { ViewState(reactTag) } + } val previousEventEmitterWrapper = viewState.eventEmitter synchronized(viewState) { @@ -1096,7 +1074,7 @@ internal constructor( // To delete we simply remove the tag from the registry. // We want to rely on the correct set of MountInstructions being sent to the platform, // or StopSurface being called, so we do not handle deleting descendants of the View. - registryRemove(reactTag) + registryLock.write { tagToViewState.remove(reactTag) } onViewStateDeleted(viewState) } @@ -1141,51 +1119,13 @@ internal constructor( } private fun getViewState(reactTag: Int): ViewState = - registryGet(reactTag) + getNullableViewState(reactTag) ?: throw RetryableMountingLayerException( "Unable to find viewState for tag $reactTag. Surface stopped: $isStopped" ) - private fun getNullableViewState(reactTag: Int): ViewState? = registryGet(reactTag) - - private fun registryGet(tag: Int): ViewState? { - return if (optimizedTagToViewState != null) { - registryLock.read { optimizedTagToViewState[tag] } - } else { - tagToViewState!![tag] - } - } - - private fun registryPut(tag: Int, state: ViewState) { - if (optimizedTagToViewState != null) { - registryLock.write { optimizedTagToViewState[tag] = state } - } else { - tagToViewState!![tag] = state - } - } - - private fun registryRemove(tag: Int) { - if (optimizedTagToViewState != null) { - registryLock.write { optimizedTagToViewState.remove(tag) } - } else { - tagToViewState!!.remove(tag) - } - } - - private fun registryContains(tag: Int): Boolean { - return if (optimizedTagToViewState != null) { - registryLock.read { optimizedTagToViewState.containsKey(tag) } - } else { - tagToViewState!!.containsKey(tag) - } - } - - private inline fun registryForEachValue(action: (ViewState) -> Unit) { - if (optimizedTagToViewState != null) { - registryLock.read { optimizedTagToViewState.forEachValue(action) } - } else { - tagToViewState!!.values.forEach(action) - } + private inline fun getNullableViewState(reactTag: Int): ViewState? = registryLock.read { + tagToViewState[reactTag] } /** Applies a bitmap as the background of the view with the given tag, if it exists. */ @@ -1197,16 +1137,18 @@ internal constructor( public fun printSurfaceState(): Unit { FLog.e(TAG, "Views created for surface $surfaceId:") - registryForEachValue { viewState -> - val viewManagerName = viewState.viewManager?.name - val view = viewState.view - val parent = if (view != null) view.parent as View? else null - val parentTag = parent?.id + registryLock.read { + tagToViewState.forEachValue { viewState -> + val viewManagerName = viewState.viewManager?.name + val view = viewState.view + val parent = if (view != null) view.parent as View? else null + val parentTag = parent?.id - FLog.e( - TAG, - "<$viewManagerName id=${viewState.reactTag} parentTag=$parentTag isRoot=${viewState.isRoot} />", - ) + FLog.e( + TAG, + "<$viewManagerName id=${viewState.reactTag} parentTag=$parentTag isRoot=${viewState.isRoot} />", + ) + } } } @@ -1219,7 +1161,7 @@ internal constructor( @EventCategoryDef eventCategory: Int, eventTimestamp: Long, ) { - val viewState = registryGet(reactTag) + val viewState = getNullableViewState(reactTag) if (viewState == null) { FLog.i(TAG, "Unable to invoke event: %s for reactTag: %d", eventName, reactTag) return 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 dc61e2a20f3..997717fe905 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<<17567d3adfba54ec2f888b50dae9efb8>> + * @generated SignedSource<> */ /** @@ -498,12 +498,6 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun useNestedScrollViewAndroid(): Boolean = accessor.useNestedScrollViewAndroid() - /** - * Use MutableIntObjectMap with ReadWriteLock instead of ConcurrentHashMap for the view registry in SurfaceMountingManager to reduce memory overhead and GC pressure. - */ - @JvmStatic - public fun useOptimizedViewRegistryOnAndroid(): Boolean = accessor.useOptimizedViewRegistryOnAndroid() - /** * Use shared animation backend in C++ Animated */ 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 7f003892085..d6cfca38701 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<<337b652caa9d443c8d83915e22210198>> + * @generated SignedSource<<5bf52aa57fc011858db9f632930bb8fb>> */ /** @@ -98,7 +98,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var useFabricInteropCache: Boolean? = null private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null private var useNestedScrollViewAndroidCache: Boolean? = null - private var useOptimizedViewRegistryOnAndroidCache: Boolean? = null private var useSharedAnimatedBackendCache: Boolean? = null private var useTraitHiddenOnAndroidCache: Boolean? = null private var useTurboModuleInteropCache: Boolean? = null @@ -809,15 +808,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } - override fun useOptimizedViewRegistryOnAndroid(): Boolean { - var cached = useOptimizedViewRegistryOnAndroidCache - if (cached == null) { - cached = ReactNativeFeatureFlagsCxxInterop.useOptimizedViewRegistryOnAndroid() - useOptimizedViewRegistryOnAndroidCache = cached - } - return cached - } - override fun useSharedAnimatedBackend(): Boolean { var cached = useSharedAnimatedBackendCache if (cached == null) { 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 98bf3882ee2..f43d355cfb1 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<> + * @generated SignedSource<<4c03e1b03360e7703ffd1d7aa0afc277>> */ /** @@ -184,8 +184,6 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun useNestedScrollViewAndroid(): Boolean - @DoNotStrip @JvmStatic public external fun useOptimizedViewRegistryOnAndroid(): Boolean - @DoNotStrip @JvmStatic public external fun useSharedAnimatedBackend(): Boolean @DoNotStrip @JvmStatic public external fun useTraitHiddenOnAndroid(): 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 4732a92c631..54ff24362e6 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<> + * @generated SignedSource<<98ed9f6f027f919cd31cd1e890750684>> */ /** @@ -179,8 +179,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun useNestedScrollViewAndroid(): Boolean = false - override fun useOptimizedViewRegistryOnAndroid(): Boolean = false - override fun useSharedAnimatedBackend(): Boolean = false override fun useTraitHiddenOnAndroid(): 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 23633e4d753..8dbf083ab9b 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<<164c9c2751f660ee098c12b8cf2c8b66>> + * @generated SignedSource<> */ /** @@ -102,7 +102,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var useFabricInteropCache: Boolean? = null private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null private var useNestedScrollViewAndroidCache: Boolean? = null - private var useOptimizedViewRegistryOnAndroidCache: Boolean? = null private var useSharedAnimatedBackendCache: Boolean? = null private var useTraitHiddenOnAndroidCache: Boolean? = null private var useTurboModuleInteropCache: Boolean? = null @@ -891,16 +890,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } - override fun useOptimizedViewRegistryOnAndroid(): Boolean { - var cached = useOptimizedViewRegistryOnAndroidCache - if (cached == null) { - cached = currentProvider.useOptimizedViewRegistryOnAndroid() - accessedFeatureFlags.add("useOptimizedViewRegistryOnAndroid") - useOptimizedViewRegistryOnAndroidCache = cached - } - return cached - } - override fun useSharedAnimatedBackend(): Boolean { var cached = useSharedAnimatedBackendCache if (cached == null) { 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 50460e763de..8855e869f5b 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<<4f18bde7c0680691cd6fceb63c41ad65>> */ /** @@ -179,8 +179,6 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun useNestedScrollViewAndroid(): Boolean - @DoNotStrip public fun useOptimizedViewRegistryOnAndroid(): Boolean - @DoNotStrip public fun useSharedAnimatedBackend(): Boolean @DoNotStrip public fun useTraitHiddenOnAndroid(): 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 04c199adaf0..bf7907626ec 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<> + * @generated SignedSource<<13e7b6ef510a97b4210de914a015ae11>> */ /** @@ -507,12 +507,6 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } - bool useOptimizedViewRegistryOnAndroid() override { - static const auto method = - getReactNativeFeatureFlagsProviderJavaClass()->getMethod("useOptimizedViewRegistryOnAndroid"); - return method(javaProvider_); - } - bool useSharedAnimatedBackend() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("useSharedAnimatedBackend"); @@ -949,11 +943,6 @@ bool JReactNativeFeatureFlagsCxxInterop::useNestedScrollViewAndroid( return ReactNativeFeatureFlags::useNestedScrollViewAndroid(); } -bool JReactNativeFeatureFlagsCxxInterop::useOptimizedViewRegistryOnAndroid( - facebook::jni::alias_ref /*unused*/) { - return ReactNativeFeatureFlags::useOptimizedViewRegistryOnAndroid(); -} - bool JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::useSharedAnimatedBackend(); @@ -1254,9 +1243,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "useNestedScrollViewAndroid", JReactNativeFeatureFlagsCxxInterop::useNestedScrollViewAndroid), - makeNativeMethod( - "useOptimizedViewRegistryOnAndroid", - JReactNativeFeatureFlagsCxxInterop::useOptimizedViewRegistryOnAndroid), makeNativeMethod( "useSharedAnimatedBackend", JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend), 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 591be913bf2..a8a0831561a 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<> + * @generated SignedSource<<4234522fd98acef7836d8050d0e7c82d>> */ /** @@ -264,9 +264,6 @@ class JReactNativeFeatureFlagsCxxInterop static bool useNestedScrollViewAndroid( facebook::jni::alias_ref); - static bool useOptimizedViewRegistryOnAndroid( - facebook::jni::alias_ref); - static bool useSharedAnimatedBackend( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 78aefa5b971..a0227722197 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<> + * @generated SignedSource<<0bafa89fa8781cb3c7aebf5d0bb8678e>> */ /** @@ -338,10 +338,6 @@ bool ReactNativeFeatureFlags::useNestedScrollViewAndroid() { return getAccessor().useNestedScrollViewAndroid(); } -bool ReactNativeFeatureFlags::useOptimizedViewRegistryOnAndroid() { - return getAccessor().useOptimizedViewRegistryOnAndroid(); -} - bool ReactNativeFeatureFlags::useSharedAnimatedBackend() { return getAccessor().useSharedAnimatedBackend(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 37e9094d1b4..f00873e7700 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<> + * @generated SignedSource<<3fca574dc84a346c113e479d0583537c>> */ /** @@ -429,11 +429,6 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool useNestedScrollViewAndroid(); - /** - * Use MutableIntObjectMap with ReadWriteLock instead of ConcurrentHashMap for the view registry in SurfaceMountingManager to reduce memory overhead and GC pressure. - */ - RN_EXPORT static bool useOptimizedViewRegistryOnAndroid(); - /** * Use shared animation backend in C++ Animated */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 0a550efaf0e..5d234f7446f 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<<1c4a88ac3f4f2d04d2e9d986536df7d9>> + * @generated SignedSource<<1ee65c6b449518e6ae582aa61effa2e3>> */ /** @@ -1433,24 +1433,6 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() { return flagValue.value(); } -bool ReactNativeFeatureFlagsAccessor::useOptimizedViewRegistryOnAndroid() { - auto flagValue = useOptimizedViewRegistryOnAndroid_.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(78, "useOptimizedViewRegistryOnAndroid"); - - flagValue = currentProvider_->useOptimizedViewRegistryOnAndroid(); - useOptimizedViewRegistryOnAndroid_ = flagValue; - } - - return flagValue.value(); -} - bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() { auto flagValue = useSharedAnimatedBackend_.load(); @@ -1460,7 +1442,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(79, "useSharedAnimatedBackend"); + markFlagAsAccessed(78, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1478,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(80, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(79, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1496,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(81, "useTurboModuleInterop"); + markFlagAsAccessed(80, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1514,7 +1496,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(82, "viewCullingOutsetRatio"); + markFlagAsAccessed(81, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1532,7 +1514,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(83, "viewTransitionEnabled"); + markFlagAsAccessed(82, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1550,7 +1532,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionUseHardwareBitmapAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(84, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(83, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1568,7 +1550,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(85, "virtualViewPrerenderRatio"); + markFlagAsAccessed(84, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 10aec19ebdc..c5419463dd3 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<<9961a0c8efe857161fb861f2873a3749>> + * @generated SignedSource<<80fcb1756caccd2259335a67984d76d5>> */ /** @@ -110,7 +110,6 @@ class ReactNativeFeatureFlagsAccessor { bool useFabricInterop(); bool useNativeViewConfigsInBridgelessMode(); bool useNestedScrollViewAndroid(); - bool useOptimizedViewRegistryOnAndroid(); bool useSharedAnimatedBackend(); bool useTraitHiddenOnAndroid(); bool useTurboModuleInterop(); @@ -129,7 +128,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 86> accessedFeatureFlags_; + std::array, 85> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; @@ -209,7 +208,6 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> useFabricInterop_; std::atomic> useNativeViewConfigsInBridgelessMode_; std::atomic> useNestedScrollViewAndroid_; - std::atomic> useOptimizedViewRegistryOnAndroid_; std::atomic> useSharedAnimatedBackend_; std::atomic> useTraitHiddenOnAndroid_; std::atomic> useTurboModuleInterop_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index d85cb77a016..42e2ddea742 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<<94d2315cb9bfc2684e18770eff3a1cf6>> */ /** @@ -339,10 +339,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } - bool useOptimizedViewRegistryOnAndroid() override { - return false; - } - bool useSharedAnimatedBackend() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index 3558ac5a30a..a2e10dda170 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<<6db86679458aa76ebb30082ba12a32ae>> + * @generated SignedSource<<215e8b28994854f31f249a5e51623c87>> */ /** @@ -747,15 +747,6 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::useNestedScrollViewAndroid(); } - bool useOptimizedViewRegistryOnAndroid() override { - auto value = values_["useOptimizedViewRegistryOnAndroid"]; - if (!value.isNull()) { - return value.getBool(); - } - - return ReactNativeFeatureFlagsDefaults::useOptimizedViewRegistryOnAndroid(); - } - bool useSharedAnimatedBackend() override { auto value = values_["useSharedAnimatedBackend"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 956231ed047..aac79cc9f56 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<> */ /** @@ -103,7 +103,6 @@ class ReactNativeFeatureFlagsProvider { virtual bool useFabricInterop() = 0; virtual bool useNativeViewConfigsInBridgelessMode() = 0; virtual bool useNestedScrollViewAndroid() = 0; - virtual bool useOptimizedViewRegistryOnAndroid() = 0; virtual bool useSharedAnimatedBackend() = 0; virtual bool useTraitHiddenOnAndroid() = 0; virtual bool useTurboModuleInterop() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 83802a95565..594d3c9d7b1 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<> */ /** @@ -434,11 +434,6 @@ bool NativeReactNativeFeatureFlags::useNestedScrollViewAndroid( return ReactNativeFeatureFlags::useNestedScrollViewAndroid(); } -bool NativeReactNativeFeatureFlags::useOptimizedViewRegistryOnAndroid( - jsi::Runtime& /*runtime*/) { - return ReactNativeFeatureFlags::useOptimizedViewRegistryOnAndroid(); -} - bool NativeReactNativeFeatureFlags::useSharedAnimatedBackend( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::useSharedAnimatedBackend(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index e29d9ac03b8..b5ddcd8a969 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<> + * @generated SignedSource<<92d22193e04fdbd6cfb119d69496c065>> */ /** @@ -192,8 +192,6 @@ class NativeReactNativeFeatureFlags bool useNestedScrollViewAndroid(jsi::Runtime& runtime); - bool useOptimizedViewRegistryOnAndroid(jsi::Runtime& runtime); - bool useSharedAnimatedBackend(jsi::Runtime& runtime); bool useTraitHiddenOnAndroid(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index be120625652..9d7ca7f313b 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -882,17 +882,6 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - useOptimizedViewRegistryOnAndroid: { - defaultValue: false, - metadata: { - dateAdded: '2026-04-28', - description: - 'Use MutableIntObjectMap with ReadWriteLock instead of ConcurrentHashMap for the view registry in SurfaceMountingManager to reduce memory overhead and GC pressure.', - expectedReleaseValue: true, - purpose: 'experimentation', - }, - ossReleaseStage: 'none', - }, useSharedAnimatedBackend: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index b3b3f6a2eca..c68254956dc 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<<785d84f617e6b1870c3ff1eeed9f1c66>> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -127,7 +127,6 @@ export type ReactNativeFeatureFlags = Readonly<{ useFabricInterop: Getter, useNativeViewConfigsInBridgelessMode: Getter, useNestedScrollViewAndroid: Getter, - useOptimizedViewRegistryOnAndroid: Getter, useSharedAnimatedBackend: Getter, useTraitHiddenOnAndroid: Getter, useTurboModuleInterop: Getter, @@ -523,10 +522,6 @@ export const useNativeViewConfigsInBridgelessMode: Getter = createNativ * When enabled, ReactScrollView will extend NestedScrollView instead of ScrollView on Android for improved nested scrolling support. */ export const useNestedScrollViewAndroid: Getter = createNativeFlagGetter('useNestedScrollViewAndroid', false); -/** - * Use MutableIntObjectMap with ReadWriteLock instead of ConcurrentHashMap for the view registry in SurfaceMountingManager to reduce memory overhead and GC pressure. - */ -export const useOptimizedViewRegistryOnAndroid: Getter = createNativeFlagGetter('useOptimizedViewRegistryOnAndroid', false); /** * Use shared animation backend in C++ Animated */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 1c2a204dff1..263f1ad402d 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<<4f1cda704a4ec31a005ded7ee8df3cbf>> + * @generated SignedSource<<6bbb0c4532c0762c4ae2dd1d7bc43fb9>> * @flow strict * @noformat */ @@ -103,7 +103,6 @@ export interface Spec extends TurboModule { readonly useFabricInterop?: () => boolean; readonly useNativeViewConfigsInBridgelessMode?: () => boolean; readonly useNestedScrollViewAndroid?: () => boolean; - readonly useOptimizedViewRegistryOnAndroid?: () => boolean; readonly useSharedAnimatedBackend?: () => boolean; readonly useTraitHiddenOnAndroid?: () => boolean; readonly useTurboModuleInterop?: () => boolean;