From bac5f1ff3a9e1bc82776db4dfb97a3ff9cbf98e7 Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Fri, 12 Jul 2024 07:34:01 -0700 Subject: [PATCH] Add feature flag to enable vector drawable support (#45394) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45394 Changelog: [Internal] The current `Image` implementation does not support loading [vector drawables](https://developer.android.com/develop/ui/views/graphics/vector-drawable-resources) on Android, and support has been requested many times ([issue](https://github.com/facebook/react-native/issues/16651), [issue](https://github.com/facebook/react-native/issues/27502)). I am proposing to put support behind this feature flag in order to validate against performance regressions. Adding support will require reading files from disk to determine if the resource is actually an XML file. Reviewed By: cortinico Differential Revision: D59647903 fbshipit-source-id: 2445d71b6769266abe4c2dda521cc2be89bf4064 --- .../featureflags/ReactNativeFeatureFlags.kt | 8 ++++- .../ReactNativeFeatureFlagsCxxAccessor.kt | 12 ++++++- .../ReactNativeFeatureFlagsCxxInterop.kt | 4 ++- .../ReactNativeFeatureFlagsDefaults.kt | 4 ++- .../ReactNativeFeatureFlagsLocalAccessor.kt | 13 ++++++- .../ReactNativeFeatureFlagsProvider.kt | 4 ++- .../JReactNativeFeatureFlagsCxxInterop.cpp | 16 ++++++++- .../JReactNativeFeatureFlagsCxxInterop.h | 5 ++- .../featureflags/ReactNativeFeatureFlags.cpp | 6 +++- .../featureflags/ReactNativeFeatureFlags.h | 7 +++- .../ReactNativeFeatureFlagsAccessor.cpp | 36 ++++++++++++++----- .../ReactNativeFeatureFlagsAccessor.h | 6 ++-- .../ReactNativeFeatureFlagsDefaults.h | 6 +++- .../ReactNativeFeatureFlagsProvider.h | 3 +- .../NativeReactNativeFeatureFlags.cpp | 7 +++- .../NativeReactNativeFeatureFlags.h | 4 ++- .../ReactNativeFeatureFlags.config.js | 5 +++ .../featureflags/ReactNativeFeatureFlags.js | 7 +++- .../specs/NativeReactNativeFeatureFlags.js | 3 +- 19 files changed, 129 insertions(+), 27 deletions(-) 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 60f790fcffc..270865175fa 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<<9f31fa21b0dd908ec53d1586c0bd271d>> + * @generated SignedSource<> */ /** @@ -148,6 +148,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun lazyAnimationCallbacks(): Boolean = accessor.lazyAnimationCallbacks() + /** + * Adds support for loading vector drawable assets in the Image component (only on Android) + */ + @JvmStatic + public fun loadVectorDrawablesOnImages(): Boolean = accessor.loadVectorDrawablesOnImages() + /** * Propagate layout direction to Android views. */ 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 bc2c35ed2a7..07559d1cfee 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<<718c08632274058c4ece4c15ed06fbfe>> + * @generated SignedSource<<03b78dd68d80c74a7be56aef64daf1e1>> */ /** @@ -40,6 +40,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso private var fuseboxEnabledReleaseCache: Boolean? = null private var initEagerTurboModulesOnNativeModulesQueueAndroidCache: Boolean? = null private var lazyAnimationCallbacksCache: Boolean? = null + private var loadVectorDrawablesOnImagesCache: Boolean? = null private var setAndroidLayoutDirectionCache: Boolean? = null private var useImmediateExecutorInAndroidBridgelessCache: Boolean? = null private var useModernRuntimeSchedulerCache: Boolean? = null @@ -229,6 +230,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso return cached } + override fun loadVectorDrawablesOnImages(): Boolean { + var cached = loadVectorDrawablesOnImagesCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.loadVectorDrawablesOnImages() + loadVectorDrawablesOnImagesCache = cached + } + return cached + } + override fun setAndroidLayoutDirection(): Boolean { var cached = setAndroidLayoutDirectionCache 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 a67e0e40d2d..f4c9ace428e 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<<9af9576364f2ec8e978604eaa1c15ee8>> + * @generated SignedSource<> */ /** @@ -68,6 +68,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun lazyAnimationCallbacks(): Boolean + @DoNotStrip @JvmStatic public external fun loadVectorDrawablesOnImages(): Boolean + @DoNotStrip @JvmStatic public external fun setAndroidLayoutDirection(): Boolean @DoNotStrip @JvmStatic public external fun useImmediateExecutorInAndroidBridgeless(): 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 e2d120fad0a..1e09c974ecf 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<<3e0a7901e165b338871f60c22f1615a9>> */ /** @@ -63,6 +63,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun lazyAnimationCallbacks(): Boolean = false + override fun loadVectorDrawablesOnImages(): Boolean = false + override fun setAndroidLayoutDirection(): Boolean = true override fun useImmediateExecutorInAndroidBridgeless(): 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 0c12b461c0a..d06c8f159f7 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<<63cb1200d25489b5cc9fcfa0061eccd0>> + * @generated SignedSource<> */ /** @@ -44,6 +44,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces private var fuseboxEnabledReleaseCache: Boolean? = null private var initEagerTurboModulesOnNativeModulesQueueAndroidCache: Boolean? = null private var lazyAnimationCallbacksCache: Boolean? = null + private var loadVectorDrawablesOnImagesCache: Boolean? = null private var setAndroidLayoutDirectionCache: Boolean? = null private var useImmediateExecutorInAndroidBridgelessCache: Boolean? = null private var useModernRuntimeSchedulerCache: Boolean? = null @@ -253,6 +254,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun loadVectorDrawablesOnImages(): Boolean { + var cached = loadVectorDrawablesOnImagesCache + if (cached == null) { + cached = currentProvider.loadVectorDrawablesOnImages() + accessedFeatureFlags.add("loadVectorDrawablesOnImages") + loadVectorDrawablesOnImagesCache = cached + } + return cached + } + override fun setAndroidLayoutDirection(): Boolean { var cached = setAndroidLayoutDirectionCache 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 b5efd53ad37..83c5f369164 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<<588266c6ec144651b7fdc84b77b490e7>> + * @generated SignedSource<<77a3249e264ca893ce8f998d424cb3db>> */ /** @@ -63,6 +63,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun lazyAnimationCallbacks(): Boolean + @DoNotStrip public fun loadVectorDrawablesOnImages(): Boolean + @DoNotStrip public fun setAndroidLayoutDirection(): Boolean @DoNotStrip public fun useImmediateExecutorInAndroidBridgeless(): 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 dcb2fbd3c4c..2cf54e27fd1 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<<9389654cf7ca12851a1af307656c807b>> + * @generated SignedSource<<61b408d16b81cca09f270c0a059166a4>> */ /** @@ -159,6 +159,12 @@ class ReactNativeFeatureFlagsProviderHolder return method(javaProvider_); } + bool loadVectorDrawablesOnImages() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("loadVectorDrawablesOnImages"); + return method(javaProvider_); + } + bool setAndroidLayoutDirection() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("setAndroidLayoutDirection"); @@ -311,6 +317,11 @@ bool JReactNativeFeatureFlagsCxxInterop::lazyAnimationCallbacks( return ReactNativeFeatureFlags::lazyAnimationCallbacks(); } +bool JReactNativeFeatureFlagsCxxInterop::loadVectorDrawablesOnImages( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::loadVectorDrawablesOnImages(); +} + bool JReactNativeFeatureFlagsCxxInterop::setAndroidLayoutDirection( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::setAndroidLayoutDirection(); @@ -428,6 +439,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "lazyAnimationCallbacks", JReactNativeFeatureFlagsCxxInterop::lazyAnimationCallbacks), + makeNativeMethod( + "loadVectorDrawablesOnImages", + JReactNativeFeatureFlagsCxxInterop::loadVectorDrawablesOnImages), makeNativeMethod( "setAndroidLayoutDirection", JReactNativeFeatureFlagsCxxInterop::setAndroidLayoutDirection), 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 8b4a761c7d6..ec4b64b70e9 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<<9d36812c37a99a514fc80e83ec056365>> + * @generated SignedSource<> */ /** @@ -90,6 +90,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool lazyAnimationCallbacks( facebook::jni::alias_ref); + static bool loadVectorDrawablesOnImages( + facebook::jni::alias_ref); + static bool setAndroidLayoutDirection( 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 b4297c3390c..15ce244e23d 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<<19c9de459447304ed033bdef70cd2cdf>> */ /** @@ -101,6 +101,10 @@ bool ReactNativeFeatureFlags::lazyAnimationCallbacks() { return getAccessor().lazyAnimationCallbacks(); } +bool ReactNativeFeatureFlags::loadVectorDrawablesOnImages() { + return getAccessor().loadVectorDrawablesOnImages(); +} + bool ReactNativeFeatureFlags::setAndroidLayoutDirection() { return getAccessor().setAndroidLayoutDirection(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 2a089c98d03..fb8577f8325 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<> */ /** @@ -137,6 +137,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool lazyAnimationCallbacks(); + /** + * Adds support for loading vector drawable assets in the Image component (only on Android) + */ + RN_EXPORT static bool loadVectorDrawablesOnImages(); + /** * Propagate layout direction to Android views. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index c929d91bce2..34229cbf127 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<<213b150588cbaf067c937cfa755791ca>> + * @generated SignedSource<<760396297e88583dbed0aea01ff73925>> */ /** @@ -389,6 +389,24 @@ bool ReactNativeFeatureFlagsAccessor::lazyAnimationCallbacks() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::loadVectorDrawablesOnImages() { + auto flagValue = loadVectorDrawablesOnImages_.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(20, "loadVectorDrawablesOnImages"); + + flagValue = currentProvider_->loadVectorDrawablesOnImages(); + loadVectorDrawablesOnImages_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::setAndroidLayoutDirection() { auto flagValue = setAndroidLayoutDirection_.load(); @@ -398,7 +416,7 @@ bool ReactNativeFeatureFlagsAccessor::setAndroidLayoutDirection() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(20, "setAndroidLayoutDirection"); + markFlagAsAccessed(21, "setAndroidLayoutDirection"); flagValue = currentProvider_->setAndroidLayoutDirection(); setAndroidLayoutDirection_ = flagValue; @@ -416,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::useImmediateExecutorInAndroidBridgeless() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(21, "useImmediateExecutorInAndroidBridgeless"); + markFlagAsAccessed(22, "useImmediateExecutorInAndroidBridgeless"); flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless(); useImmediateExecutorInAndroidBridgeless_ = flagValue; @@ -434,7 +452,7 @@ bool ReactNativeFeatureFlagsAccessor::useModernRuntimeScheduler() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(22, "useModernRuntimeScheduler"); + markFlagAsAccessed(23, "useModernRuntimeScheduler"); flagValue = currentProvider_->useModernRuntimeScheduler(); useModernRuntimeScheduler_ = flagValue; @@ -452,7 +470,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(23, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(24, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -470,7 +488,7 @@ bool ReactNativeFeatureFlagsAccessor::useNewReactImageViewBackgroundDrawing() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(24, "useNewReactImageViewBackgroundDrawing"); + markFlagAsAccessed(25, "useNewReactImageViewBackgroundDrawing"); flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing(); useNewReactImageViewBackgroundDrawing_ = flagValue; @@ -488,7 +506,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdate() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(25, "useRuntimeShadowNodeReferenceUpdate"); + markFlagAsAccessed(26, "useRuntimeShadowNodeReferenceUpdate"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate(); useRuntimeShadowNodeReferenceUpdate_ = flagValue; @@ -506,7 +524,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdateOnLayou // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(26, "useRuntimeShadowNodeReferenceUpdateOnLayout"); + markFlagAsAccessed(27, "useRuntimeShadowNodeReferenceUpdateOnLayout"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout(); useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue; @@ -524,7 +542,7 @@ bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(27, "useStateAlignmentMechanism"); + markFlagAsAccessed(28, "useStateAlignmentMechanism"); flagValue = currentProvider_->useStateAlignmentMechanism(); useStateAlignmentMechanism_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index b47082c84a2..b20f2ffaa33 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<<086584dd69b004ee0f083b76d6368f84>> + * @generated SignedSource<<514f185e84b4e4253727009281717dd8>> */ /** @@ -51,6 +51,7 @@ class ReactNativeFeatureFlagsAccessor { bool fuseboxEnabledRelease(); bool initEagerTurboModulesOnNativeModulesQueueAndroid(); bool lazyAnimationCallbacks(); + bool loadVectorDrawablesOnImages(); bool setAndroidLayoutDirection(); bool useImmediateExecutorInAndroidBridgeless(); bool useModernRuntimeScheduler(); @@ -69,7 +70,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 28> accessedFeatureFlags_; + std::array, 29> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> allowCollapsableChildren_; @@ -91,6 +92,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> fuseboxEnabledRelease_; std::atomic> initEagerTurboModulesOnNativeModulesQueueAndroid_; std::atomic> lazyAnimationCallbacks_; + std::atomic> loadVectorDrawablesOnImages_; std::atomic> setAndroidLayoutDirection_; std::atomic> useImmediateExecutorInAndroidBridgeless_; std::atomic> useModernRuntimeScheduler_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 521155c6f42..b208c9772e0 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<<108ca764e4098dab0467165c974d1278>> + * @generated SignedSource<> */ /** @@ -107,6 +107,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool loadVectorDrawablesOnImages() override { + return false; + } + bool setAndroidLayoutDirection() override { return true; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 50eb628b652..4a615f9b0d2 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<<2c5dfb357e1b7a1b27e0ff8a023fc54f>> */ /** @@ -45,6 +45,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool fuseboxEnabledRelease() = 0; virtual bool initEagerTurboModulesOnNativeModulesQueueAndroid() = 0; virtual bool lazyAnimationCallbacks() = 0; + virtual bool loadVectorDrawablesOnImages() = 0; virtual bool setAndroidLayoutDirection() = 0; virtual bool useImmediateExecutorInAndroidBridgeless() = 0; virtual bool useModernRuntimeScheduler() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 94565669519..1709265236d 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<> */ /** @@ -137,6 +137,11 @@ bool NativeReactNativeFeatureFlags::lazyAnimationCallbacks( return ReactNativeFeatureFlags::lazyAnimationCallbacks(); } +bool NativeReactNativeFeatureFlags::loadVectorDrawablesOnImages( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::loadVectorDrawablesOnImages(); +} + bool NativeReactNativeFeatureFlags::setAndroidLayoutDirection( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::setAndroidLayoutDirection(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 2435f7aa9f4..04132d8163f 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<<735fa03ec34232ee74161db833eadf25>> + * @generated SignedSource<<4f72e159b344f68fc39649f929f2b6f1>> */ /** @@ -75,6 +75,8 @@ class NativeReactNativeFeatureFlags bool lazyAnimationCallbacks(jsi::Runtime& runtime); + bool loadVectorDrawablesOnImages(jsi::Runtime& runtime); + bool setAndroidLayoutDirection(jsi::Runtime& runtime); bool useImmediateExecutorInAndroidBridgeless(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 3a4e403e6f1..aaea2650dc8 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -133,6 +133,11 @@ const definitions: FeatureFlagDefinitions = { description: 'Only enqueue Choreographer calls if there is an ongoing animation, instead of enqueueing every frame.', }, + loadVectorDrawablesOnImages: { + defaultValue: false, + description: + 'Adds support for loading vector drawable assets in the Image component (only on Android)', + }, setAndroidLayoutDirection: { defaultValue: true, description: 'Propagate layout direction to Android views.', diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 1eb0dc4b9a1..f892348f449 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<<07014a208bbac8efec4d01b7f09c6910>> + * @generated SignedSource<> * @flow strict-local */ @@ -61,6 +61,7 @@ export type ReactNativeFeatureFlags = { fuseboxEnabledRelease: Getter, initEagerTurboModulesOnNativeModulesQueueAndroid: Getter, lazyAnimationCallbacks: Getter, + loadVectorDrawablesOnImages: Getter, setAndroidLayoutDirection: Getter, useImmediateExecutorInAndroidBridgeless: Getter, useModernRuntimeScheduler: Getter, @@ -196,6 +197,10 @@ export const initEagerTurboModulesOnNativeModulesQueueAndroid: Getter = * Only enqueue Choreographer calls if there is an ongoing animation, instead of enqueueing every frame. */ export const lazyAnimationCallbacks: Getter = createNativeFlagGetter('lazyAnimationCallbacks', false); +/** + * Adds support for loading vector drawable assets in the Image component (only on Android) + */ +export const loadVectorDrawablesOnImages: Getter = createNativeFlagGetter('loadVectorDrawablesOnImages', false); /** * Propagate layout direction to Android views. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index eb3073c48db..55618a64f7f 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<> + * @generated SignedSource<<681628bb566e851c57e2831ac8f83f4f>> * @flow strict-local */ @@ -43,6 +43,7 @@ export interface Spec extends TurboModule { +fuseboxEnabledRelease?: () => boolean; +initEagerTurboModulesOnNativeModulesQueueAndroid?: () => boolean; +lazyAnimationCallbacks?: () => boolean; + +loadVectorDrawablesOnImages?: () => boolean; +setAndroidLayoutDirection?: () => boolean; +useImmediateExecutorInAndroidBridgeless?: () => boolean; +useModernRuntimeScheduler?: () => boolean;