Skip to content

Commit 0a3b3fc

Browse files
rshestfacebook-github-bot
authored andcommitted
Add RN feature flag for Image view recycling (#53600)
Summary: Pull Request resolved: #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
1 parent 2b4c48a commit 0a3b3fc

20 files changed

Lines changed: 167 additions & 50 deletions

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<a59b42b84160c18d214f8b2be76bc743>>
7+
* @generated SignedSource<<92a6edded037a504fc1c2c8ae88deae1>>
88
*/
99

1010
/**
@@ -258,6 +258,12 @@ public object ReactNativeFeatureFlags {
258258
@JvmStatic
259259
public fun enableViewRecycling(): Boolean = accessor.enableViewRecycling()
260260

261+
/**
262+
* Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.
263+
*/
264+
@JvmStatic
265+
public fun enableViewRecyclingForImage(): Boolean = accessor.enableViewRecyclingForImage()
266+
261267
/**
262268
* Enables View Recycling for <ScrollView> via ReactViewGroup/ReactViewManager.
263269
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<37203dffb9421d1036aaeaeaa7319e28>>
7+
* @generated SignedSource<<ebbc6602fc8e3fb4c510bbd47361a7f0>>
88
*/
99

1010
/**
@@ -58,6 +58,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
5858
private var enableResourceTimingAPICache: Boolean? = null
5959
private var enableViewCullingCache: Boolean? = null
6060
private var enableViewRecyclingCache: Boolean? = null
61+
private var enableViewRecyclingForImageCache: Boolean? = null
6162
private var enableViewRecyclingForScrollViewCache: Boolean? = null
6263
private var enableViewRecyclingForTextCache: Boolean? = null
6364
private var enableViewRecyclingForViewCache: Boolean? = null
@@ -431,6 +432,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
431432
return cached
432433
}
433434

435+
override fun enableViewRecyclingForImage(): Boolean {
436+
var cached = enableViewRecyclingForImageCache
437+
if (cached == null) {
438+
cached = ReactNativeFeatureFlagsCxxInterop.enableViewRecyclingForImage()
439+
enableViewRecyclingForImageCache = cached
440+
}
441+
return cached
442+
}
443+
434444
override fun enableViewRecyclingForScrollView(): Boolean {
435445
var cached = enableViewRecyclingForScrollViewCache
436446
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9c0acc876e3205fe2ea181e71eb512c9>>
7+
* @generated SignedSource<<4410628511f112f3eef22434a05fa757>>
88
*/
99

1010
/**
@@ -104,6 +104,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
104104

105105
@DoNotStrip @JvmStatic public external fun enableViewRecycling(): Boolean
106106

107+
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForImage(): Boolean
108+
107109
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForScrollView(): Boolean
108110

109111
@DoNotStrip @JvmStatic public external fun enableViewRecyclingForText(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<05bfed9fc7131062c8b16246986fc999>>
7+
* @generated SignedSource<<411732d441bacbef37c3474b9041202c>>
88
*/
99

1010
/**
@@ -99,6 +99,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
9999

100100
override fun enableViewRecycling(): Boolean = false
101101

102+
override fun enableViewRecyclingForImage(): Boolean = true
103+
102104
override fun enableViewRecyclingForScrollView(): Boolean = false
103105

104106
override fun enableViewRecyclingForText(): Boolean = true

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9a18369464f81c3d03f2702716dfdb29>>
7+
* @generated SignedSource<<2f65e0e9066a8c2c35c44ea7c73dbedc>>
88
*/
99

1010
/**
@@ -62,6 +62,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
6262
private var enableResourceTimingAPICache: Boolean? = null
6363
private var enableViewCullingCache: Boolean? = null
6464
private var enableViewRecyclingCache: Boolean? = null
65+
private var enableViewRecyclingForImageCache: Boolean? = null
6566
private var enableViewRecyclingForScrollViewCache: Boolean? = null
6667
private var enableViewRecyclingForTextCache: Boolean? = null
6768
private var enableViewRecyclingForViewCache: Boolean? = null
@@ -473,6 +474,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
473474
return cached
474475
}
475476

477+
override fun enableViewRecyclingForImage(): Boolean {
478+
var cached = enableViewRecyclingForImageCache
479+
if (cached == null) {
480+
cached = currentProvider.enableViewRecyclingForImage()
481+
accessedFeatureFlags.add("enableViewRecyclingForImage")
482+
enableViewRecyclingForImageCache = cached
483+
}
484+
return cached
485+
}
486+
476487
override fun enableViewRecyclingForScrollView(): Boolean {
477488
var cached = enableViewRecyclingForScrollViewCache
478489
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<845b2ee5edc9aedbdbd052d9a930f666>>
7+
* @generated SignedSource<<e97601660cfd4f614ac934ba20ca4635>>
88
*/
99

1010
/**
@@ -99,6 +99,8 @@ public interface ReactNativeFeatureFlagsProvider {
9999

100100
@DoNotStrip public fun enableViewRecycling(): Boolean
101101

102+
@DoNotStrip public fun enableViewRecyclingForImage(): Boolean
103+
102104
@DoNotStrip public fun enableViewRecyclingForScrollView(): Boolean
103105

104106
@DoNotStrip public fun enableViewRecyclingForText(): Boolean

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d1dda9d6cd1c0179472fcc0631e46fcd>>
7+
* @generated SignedSource<<f9c4f8d97edff1b016873b0a6121b76b>>
88
*/
99

1010
/**
@@ -267,6 +267,12 @@ class ReactNativeFeatureFlagsJavaProvider
267267
return method(javaProvider_);
268268
}
269269

270+
bool enableViewRecyclingForImage() override {
271+
static const auto method =
272+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableViewRecyclingForImage");
273+
return method(javaProvider_);
274+
}
275+
270276
bool enableViewRecyclingForScrollView() override {
271277
static const auto method =
272278
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableViewRecyclingForScrollView");
@@ -641,6 +647,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableViewRecycling(
641647
return ReactNativeFeatureFlags::enableViewRecycling();
642648
}
643649

650+
bool JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForImage(
651+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
652+
return ReactNativeFeatureFlags::enableViewRecyclingForImage();
653+
}
654+
644655
bool JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForScrollView(
645656
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
646657
return ReactNativeFeatureFlags::enableViewRecyclingForScrollView();
@@ -936,6 +947,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
936947
makeNativeMethod(
937948
"enableViewRecycling",
938949
JReactNativeFeatureFlagsCxxInterop::enableViewRecycling),
950+
makeNativeMethod(
951+
"enableViewRecyclingForImage",
952+
JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForImage),
939953
makeNativeMethod(
940954
"enableViewRecyclingForScrollView",
941955
JReactNativeFeatureFlagsCxxInterop::enableViewRecyclingForScrollView),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<31298767c1dd669d2a755e67edacc911>>
7+
* @generated SignedSource<<6a98f8398948f8d56e51d3eff19c5d05>>
88
*/
99

1010
/**
@@ -144,6 +144,9 @@ class JReactNativeFeatureFlagsCxxInterop
144144
static bool enableViewRecycling(
145145
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
146146

147+
static bool enableViewRecyclingForImage(
148+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
149+
147150
static bool enableViewRecyclingForScrollView(
148151
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
149152

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9a538d3ebb58173e7e4e34453b71454b>>
7+
* @generated SignedSource<<5bd932f1d52596dad6ea86a2674170ff>>
88
*/
99

1010
/**
@@ -178,6 +178,10 @@ bool ReactNativeFeatureFlags::enableViewRecycling() {
178178
return getAccessor().enableViewRecycling();
179179
}
180180

181+
bool ReactNativeFeatureFlags::enableViewRecyclingForImage() {
182+
return getAccessor().enableViewRecyclingForImage();
183+
}
184+
181185
bool ReactNativeFeatureFlags::enableViewRecyclingForScrollView() {
182186
return getAccessor().enableViewRecyclingForScrollView();
183187
}

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<3321d357fe5c74fa42c2d0b15a744f87>>
7+
* @generated SignedSource<<3cde1e9bcf234515551ba57ecf02e3a7>>
88
*/
99

1010
/**
@@ -229,6 +229,11 @@ class ReactNativeFeatureFlags {
229229
*/
230230
RN_EXPORT static bool enableViewRecycling();
231231

232+
/**
233+
* Enables View Recycling for <Image> via ReactViewGroup/ReactViewManager.
234+
*/
235+
RN_EXPORT static bool enableViewRecyclingForImage();
236+
232237
/**
233238
* Enables View Recycling for <ScrollView> via ReactViewGroup/ReactViewManager.
234239
*/

0 commit comments

Comments
 (0)