mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove useOptimizedViewRegistryOnAndroid feature flag (#57228)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57228 The flag gated a more memory-efficient view registry implementation in `SurfaceMountingManager` (`MutableIntObjectMap` with a `ReadWriteLock` instead of `ConcurrentHashMap`). Removing the gate, keeping the optimized path, and inlining the helper methods that previously dispatched between the two implementations. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D108415790 fbshipit-source-id: b21cbb1923cf7d15e375df8d3c3c51d187eecee3
This commit is contained in:
1 parent
a160cac8af
commit
723908a759
21 files changed
+75
-250
No files matched your search
+48
-106
@@ -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<Int, ViewState>?
|
||||
private val optimizedTagToViewState: MutableIntObjectMap<ViewState>?
|
||||
private val tagToViewState: MutableIntObjectMap<ViewState> = MutableIntObjectMap()
|
||||
private val registryLock = ReentrantReadWriteLock()
|
||||
|
||||
init {
|
||||
if (ReactNativeFeatureFlags.useOptimizedViewRegistryOnAndroid()) {
|
||||
tagToViewState = null
|
||||
optimizedTagToViewState = MutableIntObjectMap()
|
||||
} else {
|
||||
tagToViewState = ConcurrentHashMap()
|
||||
optimizedTagToViewState = null
|
||||
}
|
||||
}
|
||||
|
||||
private val onViewAttachMountItems: Queue<MountItem> = 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<ViewState>
|
||||
registryLock.write {
|
||||
val tagSetForStoppedSurface =
|
||||
SparseArrayCompat<Any>().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<Any>().also { this.tagSetForStoppedSurface = it }
|
||||
|
||||
val viewStatesToDelete: ArrayList<ViewState>
|
||||
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<Any>().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
|
||||
|
||||
+1
-7
@@ -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<<e5d648cb1649c713cac9ffaac905fc80>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+1
-11
@@ -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) {
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<b74d90991a4808bd1f3abfa75f3adcde>>
|
||||
* @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
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<efb2b99bb1697ec28c59e4d2244717ad>>
|
||||
* @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
|
||||
|
||||
+1
-12
@@ -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<<d17ebed58238939efc1b3d4a2d7fd3c7>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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) {
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<b9cfc6790e36d7f7ff0ce9b87edca1e8>>
|
||||
* @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
|
||||
|
||||
+1
-15
@@ -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<<ff63bb537a04e29fdb97e9d87fb7570c>>
|
||||
* @generated SignedSource<<13e7b6ef510a97b4210de914a015ae11>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -507,12 +507,6 @@ class ReactNativeFeatureFlagsJavaProvider
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool useOptimizedViewRegistryOnAndroid() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useOptimizedViewRegistryOnAndroid");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool useSharedAnimatedBackend() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useSharedAnimatedBackend");
|
||||
@@ -949,11 +943,6 @@ bool JReactNativeFeatureFlagsCxxInterop::useNestedScrollViewAndroid(
|
||||
return ReactNativeFeatureFlags::useNestedScrollViewAndroid();
|
||||
}
|
||||
|
||||
bool JReactNativeFeatureFlagsCxxInterop::useOptimizedViewRegistryOnAndroid(
|
||||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
|
||||
return ReactNativeFeatureFlags::useOptimizedViewRegistryOnAndroid();
|
||||
}
|
||||
|
||||
bool JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend(
|
||||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
|
||||
return ReactNativeFeatureFlags::useSharedAnimatedBackend();
|
||||
@@ -1254,9 +1243,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
|
||||
makeNativeMethod(
|
||||
"useNestedScrollViewAndroid",
|
||||
JReactNativeFeatureFlagsCxxInterop::useNestedScrollViewAndroid),
|
||||
makeNativeMethod(
|
||||
"useOptimizedViewRegistryOnAndroid",
|
||||
JReactNativeFeatureFlagsCxxInterop::useOptimizedViewRegistryOnAndroid),
|
||||
makeNativeMethod(
|
||||
"useSharedAnimatedBackend",
|
||||
JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend),
|
||||
|
||||
+1
-4
@@ -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<<a61fa73c8b01506a3eb1caa411a5854f>>
|
||||
* @generated SignedSource<<4234522fd98acef7836d8050d0e7c82d>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -264,9 +264,6 @@ class JReactNativeFeatureFlagsCxxInterop
|
||||
static bool useNestedScrollViewAndroid(
|
||||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
|
||||
|
||||
static bool useOptimizedViewRegistryOnAndroid(
|
||||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
|
||||
|
||||
static bool useSharedAnimatedBackend(
|
||||
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<<dae2de640250ff7281b56633c75712d8>>
|
||||
* @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();
|
||||
}
|
||||
|
||||
@@ -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<<e757dc80972dc0f4810cc3713516402d>>
|
||||
* @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
|
||||
*/
|
||||
|
||||
+8
-26
@@ -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;
|
||||
|
||||
+2
-4
@@ -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<ReactNativeFeatureFlagsProvider> currentProvider_;
|
||||
bool wasOverridden_;
|
||||
|
||||
std::array<std::atomic<const char*>, 86> accessedFeatureFlags_;
|
||||
std::array<std::atomic<const char*>, 85> accessedFeatureFlags_;
|
||||
|
||||
std::atomic<std::optional<bool>> commonTestFlag_;
|
||||
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
|
||||
@@ -209,7 +208,6 @@ class ReactNativeFeatureFlagsAccessor {
|
||||
std::atomic<std::optional<bool>> useFabricInterop_;
|
||||
std::atomic<std::optional<bool>> useNativeViewConfigsInBridgelessMode_;
|
||||
std::atomic<std::optional<bool>> useNestedScrollViewAndroid_;
|
||||
std::atomic<std::optional<bool>> useOptimizedViewRegistryOnAndroid_;
|
||||
std::atomic<std::optional<bool>> useSharedAnimatedBackend_;
|
||||
std::atomic<std::optional<bool>> useTraitHiddenOnAndroid_;
|
||||
std::atomic<std::optional<bool>> useTurboModuleInterop_;
|
||||
|
||||
+1
-5
@@ -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<<f4523dc9a6a32251533466d67a735e1f>>
|
||||
* @generated SignedSource<<94d2315cb9bfc2684e18770eff3a1cf6>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -339,10 +339,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool useOptimizedViewRegistryOnAndroid() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool useSharedAnimatedBackend() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-10
@@ -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()) {
|
||||
|
||||
+1
-2
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<b7eb9be59de2e2a8622aa55f543c5862>>
|
||||
* @generated SignedSource<<e5bfef755b02fbd3efb457f4bc387cf0>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
+1
-6
@@ -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<<bc20b5e74b97af62d7db4770c167fd36>>
|
||||
* @generated SignedSource<<f3ef836bc36b775e91c33d86f4fdc0d6>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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();
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<e042e064a951f6063cb8e685f75fbc29>>
|
||||
* @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);
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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<<b3888619bcbd9d40b0e1740a864a07cf>>
|
||||
* @flow strict
|
||||
* @noformat
|
||||
*/
|
||||
@@ -127,7 +127,6 @@ export type ReactNativeFeatureFlags = Readonly<{
|
||||
useFabricInterop: Getter<boolean>,
|
||||
useNativeViewConfigsInBridgelessMode: Getter<boolean>,
|
||||
useNestedScrollViewAndroid: Getter<boolean>,
|
||||
useOptimizedViewRegistryOnAndroid: Getter<boolean>,
|
||||
useSharedAnimatedBackend: Getter<boolean>,
|
||||
useTraitHiddenOnAndroid: Getter<boolean>,
|
||||
useTurboModuleInterop: Getter<boolean>,
|
||||
@@ -523,10 +522,6 @@ export const useNativeViewConfigsInBridgelessMode: Getter<boolean> = createNativ
|
||||
* When enabled, ReactScrollView will extend NestedScrollView instead of ScrollView on Android for improved nested scrolling support.
|
||||
*/
|
||||
export const useNestedScrollViewAndroid: Getter<boolean> = 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<boolean> = createNativeFlagGetter('useOptimizedViewRegistryOnAndroid', false);
|
||||
/**
|
||||
* Use shared animation backend in C++ Animated
|
||||
*/
|
||||
|
||||
+1
-2
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<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;
|
||||
|
||||
Reference in new issue
Block a user