Add RN feature flag for Image view recycling (#53600)

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

# Changelog:
[Internal] -

Adds the corresponding feature flag, similarly as it's done for other component types.

The flag is used in the next diff.

Reviewed By: mdvacca

Differential Revision: D81681404

fbshipit-source-id: f9f155379034695f5df6cc4f0d3787ff4c69df7f
This commit is contained in:
Ruslan Shestopalyuk authored and Facebook GitHub Bot committed 2025-09-04 09:47:15 -07:00
1 parent 2b4c48ae47
commit 0a3b3fcd18
20 files changed
+167 -50

No files matched your search

@@ -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<<a59b42b84160c18d214f8b2be76bc743>>
* @generated SignedSource<<92a6edded037a504fc1c2c8ae88deae1>>
*/
/**
@@ -258,6 +258,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableViewRecycling(): Boolean = accessor.enableViewRecycling()
/**
* Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.
*/
@JvmStatic
public fun enableViewRecyclingForImage(): Boolean = accessor.enableViewRecyclingForImage()
/**
* Enables View Recycling for <ScrollView> via ReactViewGroup/ReactViewManager.
*/
@@ -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<<37203dffb9421d1036aaeaeaa7319e28>>
* @generated SignedSource<<ebbc6602fc8e3fb4c510bbd47361a7f0>>
*/
/**
@@ -58,6 +58,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableResourceTimingAPICache: Boolean? = null
private var enableViewCullingCache: Boolean? = null
private var enableViewRecyclingCache: Boolean? = null
private var enableViewRecyclingForImageCache: Boolean? = null
private var enableViewRecyclingForScrollViewCache: Boolean? = null
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
@@ -431,6 +432,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableViewRecyclingForImage(): Boolean {
var cached = enableViewRecyclingForImageCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableViewRecyclingForImage()
enableViewRecyclingForImageCache = cached
}
return cached
}
override fun enableViewRecyclingForScrollView(): Boolean {
var cached = enableViewRecyclingForScrollViewCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9c0acc876e3205fe2ea181e71eb512c9>>
* @generated SignedSource<<4410628511f112f3eef22434a05fa757>>
*/
/**
@@ -104,6 +104,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableViewRecycling(): Boolean
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForImage(): Boolean
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForScrollView(): Boolean
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForText(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<05bfed9fc7131062c8b16246986fc999>>
* @generated SignedSource<<411732d441bacbef37c3474b9041202c>>
*/
/**
@@ -99,6 +99,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableViewRecycling(): Boolean = false
override fun enableViewRecyclingForImage(): Boolean = true
override fun enableViewRecyclingForScrollView(): Boolean = false
override fun enableViewRecyclingForText(): Boolean = true
@@ -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<<9a18369464f81c3d03f2702716dfdb29>>
* @generated SignedSource<<2f65e0e9066a8c2c35c44ea7c73dbedc>>
*/
/**
@@ -62,6 +62,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableResourceTimingAPICache: Boolean? = null
private var enableViewCullingCache: Boolean? = null
private var enableViewRecyclingCache: Boolean? = null
private var enableViewRecyclingForImageCache: Boolean? = null
private var enableViewRecyclingForScrollViewCache: Boolean? = null
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
@@ -473,6 +474,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun enableViewRecyclingForImage(): Boolean {
var cached = enableViewRecyclingForImageCache
if (cached == null) {
cached = currentProvider.enableViewRecyclingForImage()
accessedFeatureFlags.add("enableViewRecyclingForImage")
enableViewRecyclingForImageCache = cached
}
return cached
}
override fun enableViewRecyclingForScrollView(): Boolean {
var cached = enableViewRecyclingForScrollViewCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<845b2ee5edc9aedbdbd052d9a930f666>>
* @generated SignedSource<<e97601660cfd4f614ac934ba20ca4635>>
*/
/**
@@ -99,6 +99,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableViewRecycling(): Boolean
@DoNotStrip public fun enableViewRecyclingForImage(): Boolean
@DoNotStrip public fun enableViewRecyclingForScrollView(): Boolean
@DoNotStrip public fun enableViewRecyclingForText(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d1dda9d6cd1c0179472fcc0631e46fcd>>
* @generated SignedSource<<f9c4f8d97edff1b016873b0a6121b76b>>
*/
/**
@@ -267,6 +267,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool enableViewRecyclingForImage() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableViewRecyclingForImage");
return method(javaProvider_);
}
bool enableViewRecyclingForScrollView() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableViewRecyclingForScrollView");
@@ -641,6 +647,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableViewRecycling(
return ReactNativeFeatureFlags::enableViewRecycling();
}
bool JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForImage(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableViewRecyclingForImage();
}
bool JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForScrollView(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableViewRecyclingForScrollView();
@@ -936,6 +947,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableViewRecycling",
JReactNativeFeatureFlagsCxxInterop::enableViewRecycling),
makeNativeMethod(
"enableViewRecyclingForImage",
JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForImage),
makeNativeMethod(
"enableViewRecyclingForScrollView",
JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForScrollView),
@@ -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<<31298767c1dd669d2a755e67edacc911>>
* @generated SignedSource<<6a98f8398948f8d56e51d3eff19c5d05>>
*/
/**
@@ -144,6 +144,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableViewRecycling(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableViewRecyclingForImage(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableViewRecyclingForScrollView(
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<<9a538d3ebb58173e7e4e34453b71454b>>
* @generated SignedSource<<5bd932f1d52596dad6ea86a2674170ff>>
*/
/**
@@ -178,6 +178,10 @@ bool ReactNativeFeatureFlags::enableViewRecycling() {
return getAccessor().enableViewRecycling();
}
bool ReactNativeFeatureFlags::enableViewRecyclingForImage() {
return getAccessor().enableViewRecyclingForImage();
}
bool ReactNativeFeatureFlags::enableViewRecyclingForScrollView() {
return getAccessor().enableViewRecyclingForScrollView();
}
@@ -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<<3321d357fe5c74fa42c2d0b15a744f87>>
* @generated SignedSource<<3cde1e9bcf234515551ba57ecf02e3a7>>
*/
/**
@@ -229,6 +229,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableViewRecycling();
/**
* Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.
*/
RN_EXPORT static bool enableViewRecyclingForImage();
/**
* Enables View Recycling for <ScrollView> via ReactViewGroup/ReactViewManager.
*/
@@ -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<<041526548ef83b4afb12229a0345e29e>>
* @generated SignedSource<<bf7bb959d851abb8cd98a2eb3fa43923>>
*/
/**
@@ -713,6 +713,24 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() {
auto flagValue = enableViewRecyclingForImage_.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(38, "enableViewRecyclingForImage");
flagValue = currentProvider_->enableViewRecyclingForImage();
enableViewRecyclingForImage_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() {
auto flagValue = enableViewRecyclingForScrollView_.load();
@@ -722,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(38, "enableViewRecyclingForScrollView");
markFlagAsAccessed(39, "enableViewRecyclingForScrollView");
flagValue = currentProvider_->enableViewRecyclingForScrollView();
enableViewRecyclingForScrollView_ = flagValue;
@@ -740,7 +758,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForText() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(39, "enableViewRecyclingForText");
markFlagAsAccessed(40, "enableViewRecyclingForText");
flagValue = currentProvider_->enableViewRecyclingForText();
enableViewRecyclingForText_ = flagValue;
@@ -758,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForView() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(40, "enableViewRecyclingForView");
markFlagAsAccessed(41, "enableViewRecyclingForView");
flagValue = currentProvider_->enableViewRecyclingForView();
enableViewRecyclingForView_ = flagValue;
@@ -776,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewDebugFeatures() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(41, "enableVirtualViewDebugFeatures");
markFlagAsAccessed(42, "enableVirtualViewDebugFeatures");
flagValue = currentProvider_->enableVirtualViewDebugFeatures();
enableVirtualViewDebugFeatures_ = flagValue;
@@ -794,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewRenderState() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(42, "enableVirtualViewRenderState");
markFlagAsAccessed(43, "enableVirtualViewRenderState");
flagValue = currentProvider_->enableVirtualViewRenderState();
enableVirtualViewRenderState_ = flagValue;
@@ -812,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewWindowFocusDetection() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(43, "enableVirtualViewWindowFocusDetection");
markFlagAsAccessed(44, "enableVirtualViewWindowFocusDetection");
flagValue = currentProvider_->enableVirtualViewWindowFocusDetection();
enableVirtualViewWindowFocusDetection_ = flagValue;
@@ -830,7 +848,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(44, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
markFlagAsAccessed(45, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact();
fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue;
@@ -848,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(45, "fuseboxEnabledRelease");
markFlagAsAccessed(46, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -866,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxNetworkInspectionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(46, "fuseboxNetworkInspectionEnabled");
markFlagAsAccessed(47, "fuseboxNetworkInspectionEnabled");
flagValue = currentProvider_->fuseboxNetworkInspectionEnabled();
fuseboxNetworkInspectionEnabled_ = flagValue;
@@ -884,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::hideOffscreenVirtualViewsOnIOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(47, "hideOffscreenVirtualViewsOnIOS");
markFlagAsAccessed(48, "hideOffscreenVirtualViewsOnIOS");
flagValue = currentProvider_->hideOffscreenVirtualViewsOnIOS();
hideOffscreenVirtualViewsOnIOS_ = flagValue;
@@ -902,7 +920,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(48, "perfMonitorV2Enabled");
markFlagAsAccessed(49, "perfMonitorV2Enabled");
flagValue = currentProvider_->perfMonitorV2Enabled();
perfMonitorV2Enabled_ = flagValue;
@@ -920,7 +938,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(49, "preparedTextCacheSize");
markFlagAsAccessed(50, "preparedTextCacheSize");
flagValue = currentProvider_->preparedTextCacheSize();
preparedTextCacheSize_ = flagValue;
@@ -938,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(50, "preventShadowTreeCommitExhaustion");
markFlagAsAccessed(51, "preventShadowTreeCommitExhaustion");
flagValue = currentProvider_->preventShadowTreeCommitExhaustion();
preventShadowTreeCommitExhaustion_ = flagValue;
@@ -956,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(51, "shouldPressibilityUseW3CPointerEventsForHover");
markFlagAsAccessed(52, "shouldPressibilityUseW3CPointerEventsForHover");
flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover();
shouldPressibilityUseW3CPointerEventsForHover_ = flagValue;
@@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause()
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(52, "skipActivityIdentityAssertionOnHostPause");
markFlagAsAccessed(53, "skipActivityIdentityAssertionOnHostPause");
flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause();
skipActivityIdentityAssertionOnHostPause_ = flagValue;
@@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::sweepActiveTouchOnChildNativeGesturesAndro
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(53, "sweepActiveTouchOnChildNativeGesturesAndroid");
markFlagAsAccessed(54, "sweepActiveTouchOnChildNativeGesturesAndroid");
flagValue = currentProvider_->sweepActiveTouchOnChildNativeGesturesAndroid();
sweepActiveTouchOnChildNativeGesturesAndroid_ = flagValue;
@@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(54, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(55, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit(
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(55, "updateRuntimeShadowNodeReferencesOnCommit");
markFlagAsAccessed(56, "updateRuntimeShadowNodeReferencesOnCommit");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit();
updateRuntimeShadowNodeReferencesOnCommit_ = flagValue;
@@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(56, "useAlwaysAvailableJSErrorHandling");
markFlagAsAccessed(57, "useAlwaysAvailableJSErrorHandling");
flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling();
useAlwaysAvailableJSErrorHandling_ = flagValue;
@@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(57, "useFabricInterop");
markFlagAsAccessed(58, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeEqualsInNativeReadableArrayAndroi
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(58, "useNativeEqualsInNativeReadableArrayAndroid");
markFlagAsAccessed(59, "useNativeEqualsInNativeReadableArrayAndroid");
flagValue = currentProvider_->useNativeEqualsInNativeReadableArrayAndroid();
useNativeEqualsInNativeReadableArrayAndroid_ = flagValue;
@@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeTransformHelperAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(59, "useNativeTransformHelperAndroid");
markFlagAsAccessed(60, "useNativeTransformHelperAndroid");
flagValue = currentProvider_->useNativeTransformHelperAndroid();
useNativeTransformHelperAndroid_ = flagValue;
@@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(60, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(61, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedEventBatchingOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(61, "useOptimizedEventBatchingOnAndroid");
markFlagAsAccessed(62, "useOptimizedEventBatchingOnAndroid");
flagValue = currentProvider_->useOptimizedEventBatchingOnAndroid();
useOptimizedEventBatchingOnAndroid_ = flagValue;
@@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::useRawPropsJsiValue() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(62, "useRawPropsJsiValue");
markFlagAsAccessed(63, "useRawPropsJsiValue");
flagValue = currentProvider_->useRawPropsJsiValue();
useRawPropsJsiValue_ = flagValue;
@@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::useShadowNodeStateOnClone() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(63, "useShadowNodeStateOnClone");
markFlagAsAccessed(64, "useShadowNodeStateOnClone");
flagValue = currentProvider_->useShadowNodeStateOnClone();
useShadowNodeStateOnClone_ = flagValue;
@@ -1190,7 +1208,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(64, "useTurboModuleInterop");
markFlagAsAccessed(65, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(65, "useTurboModules");
markFlagAsAccessed(66, "useTurboModules");
flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
@@ -1226,7 +1244,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewHysteresisRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(66, "virtualViewHysteresisRatio");
markFlagAsAccessed(67, "virtualViewHysteresisRatio");
flagValue = currentProvider_->virtualViewHysteresisRatio();
virtualViewHysteresisRatio_ = flagValue;
@@ -1244,7 +1262,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(67, "virtualViewPrerenderRatio");
markFlagAsAccessed(68, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9c51131fae9f19d03050be0c74ca3d4b>>
* @generated SignedSource<<a449e9cf8f14bb7381d9779c764d0d7c>>
*/
/**
@@ -70,6 +70,7 @@ class ReactNativeFeatureFlagsAccessor {
bool enableResourceTimingAPI();
bool enableViewCulling();
bool enableViewRecycling();
bool enableViewRecyclingForImage();
bool enableViewRecyclingForScrollView();
bool enableViewRecyclingForText();
bool enableViewRecyclingForView();
@@ -111,7 +112,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 68> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 69> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -151,6 +152,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableResourceTimingAPI_;
std::atomic<std::optional<bool>> enableViewCulling_;
std::atomic<std::optional<bool>> enableViewRecycling_;
std::atomic<std::optional<bool>> enableViewRecyclingForImage_;
std::atomic<std::optional<bool>> enableViewRecyclingForScrollView_;
std::atomic<std::optional<bool>> enableViewRecyclingForText_;
std::atomic<std::optional<bool>> enableViewRecyclingForView_;
@@ -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<<5f9c3ecf7887653fd5348a05391ab7d0>>
* @generated SignedSource<<6d8adaa4b960407540afb1d6e42a3840>>
*/
/**
@@ -179,6 +179,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool enableViewRecyclingForImage() override {
return true;
}
bool enableViewRecyclingForScrollView() override {
return false;
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<027cef9dd44f14a71be7c0d1b90238b3>>
* @generated SignedSource<<ccd274f2ece9c85f23dd87e74d446ecb>>
*/
/**
@@ -387,6 +387,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::enableViewRecycling();
}
bool enableViewRecyclingForImage() override {
auto value = values_["enableViewRecyclingForImage"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::enableViewRecyclingForImage();
}
bool enableViewRecyclingForScrollView() override {
auto value = values_["enableViewRecyclingForScrollView"];
if (!value.isNull()) {
@@ -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<<a78e171b87f70a1b2ab0de2f9e48012b>>
* @generated SignedSource<<07b25b19a265e8afe53eeeffade4dfc0>>
*/
/**
@@ -63,6 +63,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableResourceTimingAPI() = 0;
virtual bool enableViewCulling() = 0;
virtual bool enableViewRecycling() = 0;
virtual bool enableViewRecyclingForImage() = 0;
virtual bool enableViewRecyclingForScrollView() = 0;
virtual bool enableViewRecyclingForText() = 0;
virtual bool enableViewRecyclingForView() = 0;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<07df05bf452f78603bbf79594aa0cba0>>
* @generated SignedSource<<348005db0ceee698cd7c33f29bcf85a6>>
*/
/**
@@ -234,6 +234,11 @@ bool NativeReactNativeFeatureFlags::enableViewRecycling(
return ReactNativeFeatureFlags::enableViewRecycling();
}
bool NativeReactNativeFeatureFlags::enableViewRecyclingForImage(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableViewRecyclingForImage();
}
bool NativeReactNativeFeatureFlags::enableViewRecyclingForScrollView(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableViewRecyclingForScrollView();
@@ -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<<228d7484ef89bb01fee8dcff2657c56a>>
* @generated SignedSource<<a27c4788a4b87366ef1e3ee03da53ab6>>
*/
/**
@@ -112,6 +112,8 @@ class NativeReactNativeFeatureFlags
bool enableViewRecycling(jsi::Runtime& runtime);
bool enableViewRecyclingForImage(jsi::Runtime& runtime);
bool enableViewRecyclingForScrollView(jsi::Runtime& runtime);
bool enableViewRecyclingForText(jsi::Runtime& runtime);
@@ -451,6 +451,17 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
enableViewRecyclingForImage: {
defaultValue: true,
metadata: {
dateAdded: '2025-09-04',
description:
'Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
enableViewRecyclingForScrollView: {
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<<7de65fc90fa1275f89375fd214b94172>>
* @generated SignedSource<<2bef8486b596a7593bbc931da63b2682>>
* @flow strict
* @noformat
*/
@@ -88,6 +88,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
enableResourceTimingAPI: Getter<boolean>,
enableViewCulling: Getter<boolean>,
enableViewRecycling: Getter<boolean>,
enableViewRecyclingForImage: Getter<boolean>,
enableViewRecyclingForScrollView: Getter<boolean>,
enableViewRecyclingForText: Getter<boolean>,
enableViewRecyclingForView: Getter<boolean>,
@@ -351,6 +352,10 @@ export const enableViewCulling: Getter<boolean> = createNativeFlagGetter('enable
* Enables View Recycling. When enabled, individual ViewManagers must still opt-in.
*/
export const enableViewRecycling: Getter<boolean> = createNativeFlagGetter('enableViewRecycling', false);
/**
* Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.
*/
export const enableViewRecyclingForImage: Getter<boolean> = createNativeFlagGetter('enableViewRecyclingForImage', true);
/**
* Enables View Recycling for <ScrollView> via ReactViewGroup/ReactViewManager.
*/
@@ -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<<1e6f17de0ebb06a085d4cc563df1e32b>>
* @generated SignedSource<<1c61b3b4390b75dab658518201379081>>
* @flow strict
* @noformat
*/
@@ -63,6 +63,7 @@ export interface Spec extends TurboModule {
+enableResourceTimingAPI?: () => boolean;
+enableViewCulling?: () => boolean;
+enableViewRecycling?: () => boolean;
+enableViewRecyclingForImage?: () => boolean;
+enableViewRecyclingForScrollView?: () => boolean;
+enableViewRecyclingForText?: () => boolean;
+enableViewRecyclingForView?: () => boolean;