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 ef31a8ebdac4..729d73ac0afe 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<<0128ee1e6f9a35114e76a548f1ccc8ab>> + * @generated SignedSource<<7d2aaa6f1519e6afa9faeab706006575>> */ /** @@ -342,6 +342,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableResizeObserverByDefault(): Boolean = accessor.enableResizeObserverByDefault() + /** + * Commits the props set by `setNativeProps` during a JS task in one shadow tree commit per surface, in a microtask, instead of one commit per call. Reads of the shadow tree from JS commit them first. Bridgeless only. + */ + @JvmStatic + public fun enableSetNativePropsBatching(): Boolean = accessor.enableSetNativePropsBatching() + /** * When enabled, it will use SwiftUI for filter effects like blur on iOS. */ 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 902076d941e2..86121bbce30e 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<> + * @generated SignedSource<<5d6259ea28fd7f45e7d8c3a14202700e>> */ /** @@ -72,6 +72,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var enablePreparedTextLayoutCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null private var enableResizeObserverByDefaultCache: Boolean? = null + private var enableSetNativePropsBatchingCache: Boolean? = null private var enableSwiftUIBasedFiltersCache: Boolean? = null private var enableViewCullingCache: Boolean? = null private var enableViewRecyclingCache: Boolean? = null @@ -590,6 +591,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableSetNativePropsBatching(): Boolean { + var cached = enableSetNativePropsBatchingCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableSetNativePropsBatching() + enableSetNativePropsBatchingCache = cached + } + return cached + } + override fun enableSwiftUIBasedFilters(): Boolean { var cached = enableSwiftUIBasedFiltersCache 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 0a0f2d537760..b256a9eb440d 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<<8606a8e4878360df1538b4218534377a>> + * @generated SignedSource<> */ /** @@ -132,6 +132,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableResizeObserverByDefault(): Boolean + @DoNotStrip @JvmStatic public external fun enableSetNativePropsBatching(): Boolean + @DoNotStrip @JvmStatic public external fun enableSwiftUIBasedFilters(): Boolean @DoNotStrip @JvmStatic public external fun enableViewCulling(): 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 5c9aeaa57505..4f575009810e 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<<49d72918b9b9df7d50b7baa9fa4aa85b>> + * @generated SignedSource<<06dcb12e5e640bb6172f260e39d17549>> */ /** @@ -127,6 +127,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableResizeObserverByDefault(): Boolean = false + override fun enableSetNativePropsBatching(): Boolean = false + override fun enableSwiftUIBasedFilters(): Boolean = false override fun enableViewCulling(): 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 bc5fdbfde0a0..9b201cef92a9 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<<0f7a0db5da3bb94bb71a0557628dcf2d>> + * @generated SignedSource<<0ecdf63083bb931a92fac84bf6b6b113>> */ /** @@ -76,6 +76,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var enablePreparedTextLayoutCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null private var enableResizeObserverByDefaultCache: Boolean? = null + private var enableSetNativePropsBatchingCache: Boolean? = null private var enableSwiftUIBasedFiltersCache: Boolean? = null private var enableViewCullingCache: Boolean? = null private var enableViewRecyclingCache: Boolean? = null @@ -646,6 +647,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun enableSetNativePropsBatching(): Boolean { + var cached = enableSetNativePropsBatchingCache + if (cached == null) { + cached = currentProvider.enableSetNativePropsBatching() + accessedFeatureFlags.add("enableSetNativePropsBatching") + enableSetNativePropsBatchingCache = cached + } + return cached + } + override fun enableSwiftUIBasedFilters(): Boolean { var cached = enableSwiftUIBasedFiltersCache 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 f0bf79a8d0d8..972d9ff301b8 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<<33bd0d69031266aecf69a8b4b216936f>> + * @generated SignedSource<<7601cb65b6770139fed6fe5fde95583d>> */ /** @@ -127,6 +127,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableResizeObserverByDefault(): Boolean + @DoNotStrip public fun enableSetNativePropsBatching(): Boolean + @DoNotStrip public fun enableSwiftUIBasedFilters(): Boolean @DoNotStrip public fun enableViewCulling(): 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 09642243526e..cf9224238e83 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<<5948daf54ab796ec4bc2754bd309cbc1>> + * @generated SignedSource<> */ /** @@ -351,6 +351,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool enableSetNativePropsBatching() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableSetNativePropsBatching"); + return method(javaProvider_); + } + bool enableSwiftUIBasedFilters() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableSwiftUIBasedFilters"); @@ -909,6 +915,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableResizeObserverByDefault( return ReactNativeFeatureFlags::enableResizeObserverByDefault(); } +bool JReactNativeFeatureFlagsCxxInterop::enableSetNativePropsBatching( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableSetNativePropsBatching(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableSwiftUIBasedFilters( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableSwiftUIBasedFilters(); @@ -1341,6 +1352,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableResizeObserverByDefault", JReactNativeFeatureFlagsCxxInterop::enableResizeObserverByDefault), + makeNativeMethod( + "enableSetNativePropsBatching", + JReactNativeFeatureFlagsCxxInterop::enableSetNativePropsBatching), makeNativeMethod( "enableSwiftUIBasedFilters", JReactNativeFeatureFlagsCxxInterop::enableSwiftUIBasedFilters), 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 8cca067f48f8..c1cd243771d8 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<<5156494ed5baa3f0ee71fc46544680f0>> + * @generated SignedSource<<9306c3f75d8dadad47db3123454f2e62>> */ /** @@ -186,6 +186,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableResizeObserverByDefault( facebook::jni::alias_ref); + static bool enableSetNativePropsBatching( + facebook::jni::alias_ref); + static bool enableSwiftUIBasedFilters( 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 3d749d83f5d5..91b7450e9bdc 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<<67d108d1c225a982e2b6d443d19ea02d>> + * @generated SignedSource<<67159cd0c2cfbd8ffda54b02498ad5b0>> */ /** @@ -234,6 +234,10 @@ bool ReactNativeFeatureFlags::enableResizeObserverByDefault() { return getAccessor().enableResizeObserverByDefault(); } +bool ReactNativeFeatureFlags::enableSetNativePropsBatching() { + return getAccessor().enableSetNativePropsBatching(); +} + bool ReactNativeFeatureFlags::enableSwiftUIBasedFilters() { return getAccessor().enableSwiftUIBasedFilters(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 902687f9d6a7..b0639efb9f1b 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<<59361ec9827f932f3f0ff8400d262580>> + * @generated SignedSource<<0091ec152736bb8470618636c88c4c03>> */ /** @@ -301,6 +301,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableResizeObserverByDefault(); + /** + * Commits the props set by `setNativeProps` during a JS task in one shadow tree commit per surface, in a microtask, instead of one commit per call. Reads of the shadow tree from JS commit them first. Bridgeless only. + */ + RN_EXPORT static bool enableSetNativePropsBatching(); + /** * When enabled, it will use SwiftUI for filter effects like blur on iOS. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index ddf2c92d9462..65fd16470ed7 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<<5bb1c26577baa01068cbf49a736017d5>> + * @generated SignedSource<> */ /** @@ -965,6 +965,24 @@ bool ReactNativeFeatureFlagsAccessor::enableResizeObserverByDefault() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableSetNativePropsBatching() { + auto flagValue = enableSetNativePropsBatching_.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(52, "enableSetNativePropsBatching"); + + flagValue = currentProvider_->enableSetNativePropsBatching(); + enableSetNativePropsBatching_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { auto flagValue = enableSwiftUIBasedFilters_.load(); @@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "enableSwiftUIBasedFilters"); + markFlagAsAccessed(53, "enableSwiftUIBasedFilters"); flagValue = currentProvider_->enableSwiftUIBasedFilters(); enableSwiftUIBasedFilters_ = flagValue; @@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewCulling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(53, "enableViewCulling"); + markFlagAsAccessed(54, "enableViewCulling"); flagValue = currentProvider_->enableViewCulling(); enableViewCulling_ = flagValue; @@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(54, "enableViewRecycling"); + markFlagAsAccessed(55, "enableViewRecycling"); flagValue = currentProvider_->enableViewRecycling(); enableViewRecycling_ = flagValue; @@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(55, "enableViewRecyclingForImage"); + markFlagAsAccessed(56, "enableViewRecyclingForImage"); flagValue = currentProvider_->enableViewRecyclingForImage(); enableViewRecyclingForImage_ = flagValue; @@ -1046,7 +1064,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(56, "enableViewRecyclingForScrollView"); + markFlagAsAccessed(57, "enableViewRecyclingForScrollView"); flagValue = currentProvider_->enableViewRecyclingForScrollView(); enableViewRecyclingForScrollView_ = flagValue; @@ -1064,7 +1082,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(57, "enableViewRecyclingForText"); + markFlagAsAccessed(58, "enableViewRecyclingForText"); flagValue = currentProvider_->enableViewRecyclingForText(); enableViewRecyclingForText_ = flagValue; @@ -1082,7 +1100,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(58, "enableViewRecyclingForView"); + markFlagAsAccessed(59, "enableViewRecyclingForView"); flagValue = currentProvider_->enableViewRecyclingForView(); enableViewRecyclingForView_ = flagValue; @@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewContainerStateExperimenta // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(59, "enableVirtualViewContainerStateExperimental"); + markFlagAsAccessed(60, "enableVirtualViewContainerStateExperimental"); flagValue = currentProvider_->enableVirtualViewContainerStateExperimental(); enableVirtualViewContainerStateExperimental_ = flagValue; @@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::fixBorderlessRippleAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(60, "fixBorderlessRippleAndroid"); + markFlagAsAccessed(61, "fixBorderlessRippleAndroid"); flagValue = currentProvider_->fixBorderlessRippleAndroid(); fixBorderlessRippleAndroid_ = flagValue; @@ -1136,7 +1154,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(61, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(62, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::fixProgrammaticScrollMomentumEventsIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(62, "fixProgrammaticScrollMomentumEventsIOS"); + markFlagAsAccessed(63, "fixProgrammaticScrollMomentumEventsIOS"); flagValue = currentProvider_->fixProgrammaticScrollMomentumEventsIOS(); fixProgrammaticScrollMomentumEventsIOS_ = flagValue; @@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextInlineViewLineHeight() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(63, "fixTextInlineViewLineHeight"); + markFlagAsAccessed(64, "fixTextInlineViewLineHeight"); flagValue = currentProvider_->fixTextInlineViewLineHeight(); fixTextInlineViewLineHeight_ = flagValue; @@ -1190,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextLayoutOnPixelDensityChange() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(64, "fixTextLayoutOnPixelDensityChange"); + markFlagAsAccessed(65, "fixTextLayoutOnPixelDensityChange"); flagValue = currentProvider_->fixTextLayoutOnPixelDensityChange(); fixTextLayoutOnPixelDensityChange_ = flagValue; @@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::fixYogaFlexBasisFitContentInMainAxis() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(65, "fixYogaFlexBasisFitContentInMainAxis"); + markFlagAsAccessed(66, "fixYogaFlexBasisFitContentInMainAxis"); flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis(); fixYogaFlexBasisFitContentInMainAxis_ = flagValue; @@ -1226,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(66, "fuseboxAssertSingleHostState"); + markFlagAsAccessed(67, "fuseboxAssertSingleHostState"); flagValue = currentProvider_->fuseboxAssertSingleHostState(); fuseboxAssertSingleHostState_ = flagValue; @@ -1244,7 +1262,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(67, "fuseboxEnabledRelease"); + markFlagAsAccessed(68, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -1262,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxFrameRecordingEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(68, "fuseboxFrameRecordingEnabled"); + markFlagAsAccessed(69, "fuseboxFrameRecordingEnabled"); flagValue = currentProvider_->fuseboxFrameRecordingEnabled(); fuseboxFrameRecordingEnabled_ = flagValue; @@ -1280,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxScreenshotCaptureEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(69, "fuseboxScreenshotCaptureEnabled"); + markFlagAsAccessed(70, "fuseboxScreenshotCaptureEnabled"); flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled(); fuseboxScreenshotCaptureEnabled_ = flagValue; @@ -1298,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxWebSocketEventsEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(70, "fuseboxWebSocketEventsEnabled"); + markFlagAsAccessed(71, "fuseboxWebSocketEventsEnabled"); flagValue = currentProvider_->fuseboxWebSocketEventsEnabled(); fuseboxWebSocketEventsEnabled_ = flagValue; @@ -1316,7 +1334,7 @@ bool ReactNativeFeatureFlagsAccessor::keepTimersRunningWhileHostPausedAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(71, "keepTimersRunningWhileHostPausedAndroid"); + markFlagAsAccessed(72, "keepTimersRunningWhileHostPausedAndroid"); flagValue = currentProvider_->keepTimersRunningWhileHostPausedAndroid(); keepTimersRunningWhileHostPausedAndroid_ = flagValue; @@ -1334,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::optimizedAnimatedPropUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(72, "optimizedAnimatedPropUpdates"); + markFlagAsAccessed(73, "optimizedAnimatedPropUpdates"); flagValue = currentProvider_->optimizedAnimatedPropUpdates(); optimizedAnimatedPropUpdates_ = flagValue; @@ -1352,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(73, "overrideBySynchronousMountPropsAtMountingAndroid"); + markFlagAsAccessed(74, "overrideBySynchronousMountPropsAtMountingAndroid"); flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid(); overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue; @@ -1370,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(74, "perfIssuesEnabled"); + markFlagAsAccessed(75, "perfIssuesEnabled"); flagValue = currentProvider_->perfIssuesEnabled(); perfIssuesEnabled_ = flagValue; @@ -1388,7 +1406,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(75, "perfMonitorV2Enabled"); + markFlagAsAccessed(76, "perfMonitorV2Enabled"); flagValue = currentProvider_->perfMonitorV2Enabled(); perfMonitorV2Enabled_ = flagValue; @@ -1406,7 +1424,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(76, "preparedTextCacheSize"); + markFlagAsAccessed(77, "preparedTextCacheSize"); flagValue = currentProvider_->preparedTextCacheSize(); preparedTextCacheSize_ = flagValue; @@ -1424,7 +1442,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(77, "preventShadowTreeCommitExhaustion"); + markFlagAsAccessed(78, "preventShadowTreeCommitExhaustion"); flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); preventShadowTreeCommitExhaustion_ = flagValue; @@ -1442,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2Android() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(78, "redBoxV2Android"); + markFlagAsAccessed(79, "redBoxV2Android"); flagValue = currentProvider_->redBoxV2Android(); redBoxV2Android_ = flagValue; @@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2IOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(79, "redBoxV2IOS"); + markFlagAsAccessed(80, "redBoxV2IOS"); flagValue = currentProvider_->redBoxV2IOS(); redBoxV2IOS_ = flagValue; @@ -1478,7 +1496,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(80, "shouldPressibilityUseW3CPointerEventsForHover"); + markFlagAsAccessed(81, "shouldPressibilityUseW3CPointerEventsForHover"); flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; @@ -1496,7 +1514,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(81, "shouldTriggerResponderTransferOnScrollAndroid"); + markFlagAsAccessed(82, "shouldTriggerResponderTransferOnScrollAndroid"); flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid(); shouldTriggerResponderTransferOnScrollAndroid_ = flagValue; @@ -1514,7 +1532,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(82, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(83, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -1532,7 +1550,7 @@ bool ReactNativeFeatureFlagsAccessor::skipNativePropsForViewManagerWithDelegateA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(83, "skipNativePropsForViewManagerWithDelegateAndroid"); + markFlagAsAccessed(84, "skipNativePropsForViewManagerWithDelegateAndroid"); flagValue = currentProvider_->skipNativePropsForViewManagerWithDelegateAndroid(); skipNativePropsForViewManagerWithDelegateAndroid_ = flagValue; @@ -1550,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::skipUnchangedChildrenInDifferentiator() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(84, "skipUnchangedChildrenInDifferentiator"); + markFlagAsAccessed(85, "skipUnchangedChildrenInDifferentiator"); flagValue = currentProvider_->skipUnchangedChildrenInDifferentiator(); skipUnchangedChildrenInDifferentiator_ = flagValue; @@ -1568,7 +1586,7 @@ bool ReactNativeFeatureFlagsAccessor::syncAndroidClipBoundsWithOverflow() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(85, "syncAndroidClipBoundsWithOverflow"); + markFlagAsAccessed(86, "syncAndroidClipBoundsWithOverflow"); flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow(); syncAndroidClipBoundsWithOverflow_ = flagValue; @@ -1586,7 +1604,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(86, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(87, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -1604,7 +1622,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(87, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(88, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -1622,7 +1640,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommitT // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(88, "updateRuntimeShadowNodeReferencesOnCommitThread"); + markFlagAsAccessed(89, "updateRuntimeShadowNodeReferencesOnCommitThread"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread(); updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue; @@ -1640,7 +1658,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(89, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(90, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -1658,7 +1676,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(90, "useFabricInterop"); + markFlagAsAccessed(91, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1676,7 +1694,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(91, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(92, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1694,7 +1712,7 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(92, "useNestedScrollViewAndroid"); + markFlagAsAccessed(93, "useNestedScrollViewAndroid"); flagValue = currentProvider_->useNestedScrollViewAndroid(); useNestedScrollViewAndroid_ = flagValue; @@ -1712,7 +1730,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(93, "useSharedAnimatedBackend"); + markFlagAsAccessed(94, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1730,7 +1748,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(94, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(95, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1748,7 +1766,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(95, "useTurboModuleInterop"); + markFlagAsAccessed(96, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1766,7 +1784,7 @@ bool ReactNativeFeatureFlagsAccessor::useWindowDensityForDisplayMetricsAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(96, "useWindowDensityForDisplayMetricsAndroid"); + markFlagAsAccessed(97, "useWindowDensityForDisplayMetricsAndroid"); flagValue = currentProvider_->useWindowDensityForDisplayMetricsAndroid(); useWindowDensityForDisplayMetricsAndroid_ = flagValue; @@ -1784,7 +1802,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(97, "viewCullingOutsetRatio"); + markFlagAsAccessed(98, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1802,7 +1820,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(98, "viewTransitionEnabled"); + markFlagAsAccessed(99, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1820,7 +1838,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(99, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(100, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1838,7 +1856,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(100, "virtualViewPrerenderRatio"); + markFlagAsAccessed(101, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 650fef0d0d88..15f43ba6c913 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<<0ede0b5ce319a8416c3b3d848cc7a726>> + * @generated SignedSource<<36081f8cd677c214628fdf36977be661>> */ /** @@ -86,6 +86,7 @@ class ReactNativeFeatureFlagsAccessor { bool enablePreparedTextLayout(); bool enablePropsUpdateReconciliationAndroid(); bool enableResizeObserverByDefault(); + bool enableSetNativePropsBatching(); bool enableSwiftUIBasedFilters(); bool enableViewCulling(); bool enableViewRecycling(); @@ -146,7 +147,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 101> accessedFeatureFlags_; + std::array, 102> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; @@ -200,6 +201,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> enablePreparedTextLayout_; std::atomic> enablePropsUpdateReconciliationAndroid_; std::atomic> enableResizeObserverByDefault_; + std::atomic> enableSetNativePropsBatching_; std::atomic> enableSwiftUIBasedFilters_; std::atomic> enableViewCulling_; std::atomic> enableViewRecycling_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 9e2ab7219bcc..dc0847a9ca43 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<<1a71fb4528797b171985c1f778c00741>> + * @generated SignedSource<<2726cd81acd67ce7488f308cf7dc12c9>> */ /** @@ -237,6 +237,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableSetNativePropsBatching() override { + return false; + } + bool enableSwiftUIBasedFilters() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index 1496b70f1791..e497917bc5b9 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -515,6 +515,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::enableResizeObserverByDefault(); } + bool enableSetNativePropsBatching() override { + auto value = values_["enableSetNativePropsBatching"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::enableSetNativePropsBatching(); + } + bool enableSwiftUIBasedFilters() override { auto value = values_["enableSwiftUIBasedFilters"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 0d9e233f2b5a..49beaf1a986f 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<<5e1a9381d32baeeddbb848c7d2fc2b63>> + * @generated SignedSource<<5cf08fd5dca653c3980e209e926705e7>> */ /** @@ -79,6 +79,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool enablePreparedTextLayout() = 0; virtual bool enablePropsUpdateReconciliationAndroid() = 0; virtual bool enableResizeObserverByDefault() = 0; + virtual bool enableSetNativePropsBatching() = 0; virtual bool enableSwiftUIBasedFilters() = 0; virtual bool enableViewCulling() = 0; virtual bool enableViewRecycling() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp b/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp index 3a24d57807e3..2402c228dbe2 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp @@ -484,7 +484,7 @@ void NativeDOM::setNativeProps( std::shared_ptr shadowNode, jsi::Value updatePayload) { getUIManagerFromRuntime(rt).setNativeProps_DEPRECATED( - shadowNode, RawProps(rt, updatePayload)); + rt, shadowNode, RawProps(rt, updatePayload)); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 27c4893e71e6..96e336d54e67 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<<10ba079ca6ecdd4686b6b8fc2dbd66ae>> */ /** @@ -304,6 +304,11 @@ bool NativeReactNativeFeatureFlags::enableResizeObserverByDefault( return ReactNativeFeatureFlags::enableResizeObserverByDefault(); } +bool NativeReactNativeFeatureFlags::enableSetNativePropsBatching( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableSetNativePropsBatching(); +} + bool NativeReactNativeFeatureFlags::enableSwiftUIBasedFilters( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableSwiftUIBasedFilters(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 367a6b20c591..2f3cb2dfad40 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<5643615db522125fa3346babd53a6a29>> */ /** @@ -142,6 +142,8 @@ class NativeReactNativeFeatureFlags bool enableResizeObserverByDefault(jsi::Runtime& runtime); + bool enableSetNativePropsBatching(jsi::Runtime& runtime); + bool enableSwiftUIBasedFilters(jsi::Runtime& runtime); bool enableViewCulling(jsi::Runtime& runtime); diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index 6a18881fd844..515fd57de9ec 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -46,6 +46,49 @@ namespace facebook::react { // used by getNativeState method) ShadowNodeListWrapper::~ShadowNodeListWrapper() = default; +namespace { + +void updateNativeProps( + const ShadowNodeFamily& family, + const folly::dynamic& rawProps) { + std::lock_guard lock(family.nativePropsMutex); + if (family.nativeProps_DEPRECATED) { + // Values in `rawProps` patch (take precedence over) + // `nativeProps_DEPRECATED`. For example, if both + // `nativeProps_DEPRECATED` and `rawProps` contain key 'A'. Value from + // `rawProps` overrides what was previously in `nativeProps_DEPRECATED`. + family.nativeProps_DEPRECATED = + std::make_unique( + mergeDynamicProps( + family.nativeProps_DEPRECATED->props, + rawProps, + NullValueStrategy::Override)); + } else { + family.nativeProps_DEPRECATED = + std::make_unique(rawProps); + } +} + +} // namespace + +// Commits the nodes queued by `setNativeProps` before returning a revision, so +// JS reads see every earlier call. +class UIManager::PendingNativePropsRevisionProvider final + : public ShadowTreeRevisionProvider { + public: + explicit PendingNativePropsRevisionProvider(const UIManager& uiManager) + : uiManager_(uiManager) {} + + RootShadowNode::Shared getCurrentRevision(SurfaceId surfaceId) override { + uiManager_.commitPendingNativeProps(); + return uiManager_.lazyShadowTreeRevisionConsistencyManager_ + ->getCurrentRevision(surfaceId); + } + + private: + const UIManager& uiManager_; +}; + UIManager::UIManager( const RuntimeExecutor& runtimeExecutor, std::shared_ptr contextContainer) @@ -55,7 +98,9 @@ UIManager::UIManager( leakChecker_(constructLeakCheckerIfNeeded(runtimeExecutor)), lazyShadowTreeRevisionConsistencyManager_( std::make_unique( - shadowTreeRegistry_)) {} + shadowTreeRegistry_)), + pendingNativePropsRevisionProvider_( + std::make_unique(*this)) {} UIManager::~UIManager() { LOG(WARNING) << "UIManager::~UIManager() was called (address: " << this @@ -361,7 +406,15 @@ UIManager::getShadowTreeRevisionConsistencyManager() { return lazyShadowTreeRevisionConsistencyManager_.get(); } +bool UIManager::isSetNativePropsBatchingEnabled() { + return ReactNativeFeatureFlags::enableSetNativePropsBatching() && + ReactNativeFeatureFlags::enableBridgelessArchitecture(); +} + ShadowTreeRevisionProvider* UIManager::getShadowTreeRevisionProvider() { + if (isSetNativePropsBatchingEnabled()) { + return pendingNativePropsRevisionProvider_.get(); + } return lazyShadowTreeRevisionConsistencyManager_.get(); } @@ -464,25 +517,7 @@ void UIManager::setNativeProps_DEPRECATED( const std::shared_ptr& shadowNode, RawProps rawProps) const { auto& family = shadowNode->getFamily(); - { - std::lock_guard lock(family.nativePropsMutex); - if (family.nativeProps_DEPRECATED) { - // Values in `rawProps` patch (take precedence over) - // `nativeProps_DEPRECATED`. For example, if both - // `nativeProps_DEPRECATED` and `rawProps` contain key 'A'. Value from - // `rawProps` overrides what was previously in `nativeProps_DEPRECATED`. - family.nativeProps_DEPRECATED = - std::make_unique( - mergeDynamicProps( - family.nativeProps_DEPRECATED->props, - (folly::dynamic)rawProps, - NullValueStrategy::Override)); - } else { - family.nativeProps_DEPRECATED = - std::make_unique( - (folly::dynamic)rawProps); - } - } + updateNativeProps(family, (folly::dynamic)rawProps); shadowTreeRegistry_.visit( family.getSurfaceId(), [&](const ShadowTree& shadowTree) { @@ -514,6 +549,118 @@ void UIManager::setNativeProps_DEPRECATED( }); } +void UIManager::setNativeProps_DEPRECATED( + jsi::Runtime& runtime, + const std::shared_ptr& shadowNode, + RawProps rawProps) const { + if (!isSetNativePropsBatchingEnabled()) { + setNativeProps_DEPRECATED(shadowNode, std::move(rawProps)); + return; + } + + auto& family = shadowNode->getFamily(); + auto props = (folly::dynamic)rawProps; + updateNativeProps(family, props); + + bool isFirstInBatch = false; + { + std::lock_guard lock(pendingNativePropsMutex_); + isFirstInBatch = pendingNativeProps_.empty(); + auto& pendingNames = pendingNativeProps_[family.getSurfaceId()] + [shadowNode->getFamilyShared()]; + for (const auto& name : props.keys()) { + pendingNames.insert(name.getString()); + } + } + if (isFirstInBatch) { + // Committing in a microtask keeps these calls ahead of the observers and + // mount that follow them in the task. + runtime.queueMicrotask( + jsi::Function::createFromHostFunction( + runtime, + jsi::PropNameID::forAscii(runtime, "commitPendingNativeProps"), + 0, + [this]( + jsi::Runtime&, const jsi::Value&, const jsi::Value*, size_t) { + commitPendingNativeProps(); + return jsi::Value::undefined(); + })); + } +} + +void UIManager::commitPendingNativeProps() const { + decltype(pendingNativeProps_) pendingNativeProps; + { + std::lock_guard lock(pendingNativePropsMutex_); + pendingNativeProps.swap(pendingNativeProps_); + } + + for (const auto& surfacePendingNames : pendingNativeProps) { + // Not a structured binding, which lambdas can't capture before Clang 16. + auto surfaceId = surfacePendingNames.first; + const auto& pendingNames = surfacePendingNames.second; + TraceSection s( + "UIManager::commitPendingNativeProps", + "surfaceId", + surfaceId, + "nodes", + pendingNames.size()); + + std::unordered_set> families; + for (const auto& [family, names] : pendingNames) { + families.insert(family); + } + + // The node's props with the props set in this batch applied, taking their + // current values, which React may have updated since. Other nodes get + // placeholder props, as in the unbatched path. + PropsParserContext propsParserContext{surfaceId, *contextContainer_}; + auto propsWithPendingProps = + [&](const ShadowNode& shadowNode) -> Props::Shared { + auto it = pendingNames.find(shadowNode.getFamilyShared()); + if (it == pendingNames.end()) { + return ShadowNodeFragment::propsPlaceholder(); + } + folly::dynamic currentProps = folly::dynamic::object; + { + const auto& family = *it->first; + std::lock_guard lock(family.nativePropsMutex); + for (const auto& name : it->second) { + currentProps[name] = family.nativeProps_DEPRECATED->props.at(name); + } + } + return shadowNode.getComponentDescriptor().cloneProps( + propsParserContext, + shadowNode.getProps(), + RawProps(std::move(currentProps))); + }; + + shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree& shadowTree) { + // With commit branching, a React commit earlier in the task replaces the + // main branch when it's merged, so these go on top of it instead. + ShadowTree::CommitOptions commitOptions; + if (shadowTree.getCurrentReactRevision().has_value()) { + commitOptions = { + .mountSynchronously = false, + .source = ShadowTree::CommitSource::React}; + } + shadowTree.commit( + [&](const RootShadowNode& oldRootShadowNode) { + return std::static_pointer_cast( + oldRootShadowNode.cloneMultiple( + families, + [&](const ShadowNode& oldShadowNode, + const ShadowNodeFragment& fragment) { + return oldShadowNode.clone( + {.props = propsWithPendingProps(oldShadowNode), + .children = fragment.children}); + })); + }, + commitOptions); + }); + } +} + void UIManager::sendAccessibilityEvent( const std::shared_ptr& shadowNode, const std::string& eventType) { diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h index 541d57a0b258..645310d3a6d8 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h @@ -28,9 +28,11 @@ #include #include #include +#include #include #include #include +#include #include namespace facebook::react { @@ -204,6 +206,16 @@ class UIManager final : public ShadowTreeDelegate { void setNativeProps_DEPRECATED(const std::shared_ptr &shadowNode, RawProps rawProps) const; + /* + * `setNativeProps` called from JS. With `enableSetNativePropsBatching` and + * bridgeless, the calls made in a task are committed together, in a + * microtask. + */ + void setNativeProps_DEPRECATED( + jsi::Runtime &runtime, + const std::shared_ptr &shadowNode, + RawProps rawProps) const; + void sendAccessibilityEvent(const std::shared_ptr &shadowNode, const std::string &eventType); /* @@ -237,6 +249,20 @@ class UIManager final : public ShadowTreeDelegate { friend class Scheduler; friend class SurfaceHandler; + class PendingNativePropsRevisionProvider; + + /* + * Whether `setNativeProps` calls from JS are batched. Batching relies on the + * runtime draining microtasks, which it does only when bridgeless. + */ + static bool isSetNativePropsBatchingEnabled(); + + /* + * Commits the nodes queued by batched `setNativeProps` calls: in a microtask + * queued by the first of them, or earlier if JS reads the shadow tree. + */ + void commitPendingNativeProps() const; + /** * Configure a LayoutAnimation to happen on the next commit. * This API configures a global LayoutAnimation starting from the root node. @@ -270,6 +296,15 @@ class UIManager final : public ShadowTreeDelegate { std::unique_ptr leakChecker_; std::unique_ptr lazyShadowTreeRevisionConsistencyManager_; + std::unique_ptr pendingNativePropsRevisionProvider_; + + // The names of the props that batched `setNativeProps` calls set, by surface + // and node. + mutable std::mutex pendingNativePropsMutex_; + mutable std::unordered_map< + SurfaceId, + std::unordered_map, std::unordered_set>> + pendingNativeProps_; std::shared_ptr animationBackend_; }; diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index a3fcfa76cf81..57d84b7d93d2 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -319,6 +319,9 @@ jsi::Value UIManagerBinding::get( auto locationY = (Float)arguments[2].getNumber(); auto onSuccessFunction = arguments[3].getObject(runtime).getFunction(runtime); + if (UIManager::isSetNativePropsBatchingEnabled()) { + uiManager->commitPendingNativeProps(); + } auto targetNode = uiManager->findNodeAtPoint( node, Point{.x = locationX, .y = locationY}); @@ -547,6 +550,9 @@ jsi::Value UIManagerBinding::get( size_t count) -> jsi::Value { validateArgumentCount(runtime, methodName, paramCount, count); + if (UIManager::isSetNativePropsBatchingEnabled()) { + uiManager->commitPendingNativeProps(); + } auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *Bridging>::fromJs( runtime, arguments[0]), @@ -604,6 +610,7 @@ jsi::Value UIManagerBinding::get( validateArgumentCount(runtime, methodName, paramCount, count); uiManager->setNativeProps_DEPRECATED( + runtime, Bridging>::fromJs( runtime, arguments[0]), RawProps(runtime, arguments[1])); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index a52454e8f33d..5ff654c49c46 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -608,6 +608,17 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, + enableSetNativePropsBatching: { + defaultValue: false, + metadata: { + dateAdded: '2026-11-27', + description: + 'Commits the props set by `setNativeProps` during a JS task in one shadow tree commit per surface, in a microtask, instead of one commit per call. Reads of the shadow tree from JS commit them first. Bridgeless only.', + expectedReleaseValue: true, + purpose: 'experimentation', + }, + ossReleaseStage: 'none', + }, enableSwiftUIBasedFilters: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 410028a14796..975e472978c1 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<<22b28ed43914155e9274821135c34ccb>> + * @generated SignedSource<<7ebfa81a7946dbef40d8aaf735ab20c0>> * @flow strict * @noformat */ @@ -100,6 +100,7 @@ export type ReactNativeFeatureFlags = Readonly<{ enablePreparedTextLayout: Getter, enablePropsUpdateReconciliationAndroid: Getter, enableResizeObserverByDefault: Getter, + enableSetNativePropsBatching: Getter, enableSwiftUIBasedFilters: Getter, enableViewCulling: Getter, enableViewRecycling: Getter, @@ -428,6 +429,10 @@ export const enablePropsUpdateReconciliationAndroid: Getter = createNat * Enables the ResizeObserver Web API in React Native. */ export const enableResizeObserverByDefault: Getter = createNativeFlagGetter('enableResizeObserverByDefault', false); +/** + * Commits the props set by `setNativeProps` during a JS task in one shadow tree commit per surface, in a microtask, instead of one commit per call. Reads of the shadow tree from JS commit them first. Bridgeless only. + */ +export const enableSetNativePropsBatching: Getter = createNativeFlagGetter('enableSetNativePropsBatching', false); /** * When enabled, it will use SwiftUI for filter effects like blur on iOS. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index e8d8030401ac..7f8166aa2534 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<<0c5bdeb1cfffe9a80487556ddd8f8eae>> * @flow strict * @noformat */ @@ -77,6 +77,7 @@ export interface Spec extends TurboModule { readonly enablePreparedTextLayout?: () => boolean; readonly enablePropsUpdateReconciliationAndroid?: () => boolean; readonly enableResizeObserverByDefault?: () => boolean; + readonly enableSetNativePropsBatching?: () => boolean; readonly enableSwiftUIBasedFilters?: () => boolean; readonly enableViewCulling?: () => boolean; readonly enableViewRecycling?: () => boolean; diff --git a/packages/react-native/src/private/renderer/mounting/__tests__/SetNativeProps-itest.js b/packages/react-native/src/private/renderer/mounting/__tests__/SetNativeProps-itest.js new file mode 100644 index 000000000000..33a4899027f5 --- /dev/null +++ b/packages/react-native/src/private/renderer/mounting/__tests__/SetNativeProps-itest.js @@ -0,0 +1,370 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @fantom_flags enableSetNativePropsBatching:* enableFabricCommitBranching:* + * @fantom_flags enableResizeObserverByDefault:true useSharedAnimatedBackend:true + * @flow strict-local + * @format + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; + +import type ResizeObserverType from '../../../webapis/resizeobserver/ResizeObserver'; +import type {Root} from '@react-native/fantom'; +import type {HostInstance} from 'react-native'; + +import {getFabricUIManager} from '../../../../../Libraries/ReactNative/FabricUIManager'; +import * as Fantom from '@react-native/fantom'; +import nullthrows from 'nullthrows'; +import * as React from 'react'; +import {useState} from 'react'; +import {Animated, View} from 'react-native'; +import { + ReactNativeFeatureFlags, + getInternalInstanceHandleFromPublicInstance, + getNodeFromPublicInstance, +} from 'react-native/react-private-interface'; + +declare const ResizeObserver: Class; + +const UIManager = nullthrows(getFabricUIManager()); + +function renderSiblings( + root: Root, + refs: ReadonlyArray>, +) { + Fantom.runTask(() => { + root.render( + + {refs.map((ref, index) => ( + + ))} + , + ); + }); +} + +describe('setNativeProps', () => { + test('applies the props from every call in a task', () => { + const root = Fantom.createRoot(); + const refs = [ + React.createRef(), + React.createRef(), + React.createRef(), + ]; + renderSiblings(root, refs); + + Fantom.runTask(() => { + refs.forEach((ref, index) => { + nullthrows(ref.current).setNativeProps({testID: `test-${index}`}); + }); + }); + + expect( + root.getRenderedOutput({props: ['nativeID', 'testID']}).toJSX(), + ).toEqual( + + + + + , + ); + }); + + test('applies calls on one node in order', () => { + const root = Fantom.createRoot(); + const ref = React.createRef(); + renderSiblings(root, [ref]); + + Fantom.runTask(() => { + const element = nullthrows(ref.current); + element.setNativeProps({testID: 'first', accessibilityLabel: 'label'}); + element.setNativeProps({testID: 'second'}); + }); + + expect( + root.getRenderedOutput({props: ['testID', 'accessibilityLabel']}).toJSX(), + ).toEqual( + + + , + ); + }); + + test('applies only the props it sets', () => { + const root = Fantom.createRoot(); + const ref = React.createRef(); + const marginLeft = new Animated.Value(0); + + Fantom.runTask(() => { + root.render(); + }); + Fantom.runTask(() => { + nullthrows(ref.current).setNativeProps({style: {marginLeft: 0}}); + }); + + // A native-driven animation changes the prop without `setNativeProps`. + Fantom.runTask(() => { + Animated.timing(marginLeft, { + toValue: 100, + duration: 200, + useNativeDriver: true, + }).start(); + }); + Fantom.unstable_produceFramesForDuration(100); + + Fantom.runTask(() => { + nullthrows(ref.current).setNativeProps({testID: 'native'}); + }); + + expect( + root.getRenderedOutput({props: ['marginLeft', 'testID']}).toJSX(), + ).toEqual(); + // The animation is left running: when it ends with commit branching on, + // `AnimationBackend`'s end-of-animation commit fails an assertion. + }); + + describe('is visible to reads later in the task', () => { + function renderHalfWidthChild(root: Root) { + const parentRef = React.createRef(); + const childRef = React.createRef(); + Fantom.runTask(() => { + root.render( + + + , + ); + }); + return [nullthrows(parentRef.current), nullthrows(childRef.current)]; + } + + test('getBoundingClientRect', () => { + const root = Fantom.createRoot(); + const [, child] = renderHalfWidthChild(root); + + let width: ?number = null; + Fantom.runTask(() => { + child.setNativeProps({style: {width: 100}}); + width = child.getBoundingClientRect().width; + }); + + expect(width).toBe(100); + }); + + // These read the tree through the Fabric UI manager directly, as the + // inspector and legacy UIManager APIs do. + test('findNodeAtPoint', () => { + const root = Fantom.createRoot(); + const [parent, child] = renderHalfWidthChild(root); + + let hit = null; + Fantom.runTask(() => { + child.setNativeProps({style: {width: 100}}); + UIManager.findNodeAtPoint( + nullthrows(getNodeFromPublicInstance(parent)), + 75, + 50, + instanceHandle => { + hit = instanceHandle; + }, + ); + }); + + expect(hit).toBe(getInternalInstanceHandleFromPublicInstance(child)); + }); + + test('getRelativeLayoutMetrics', () => { + const root = Fantom.createRoot(); + const [parent, child] = renderHalfWidthChild(root); + + let width: ?number = null; + Fantom.runTask(() => { + child.setNativeProps({style: {width: 100}}); + width = UIManager.getRelativeLayoutMetrics( + nullthrows(getNodeFromPublicInstance(child)), + nullthrows(getNodeFromPublicInstance(parent)), + ).width; + }); + + expect(width).toBe(100); + }); + }); + + test('is visible to ResizeObserver in the same task', () => { + const root = Fantom.createRoot(); + const ref = React.createRef(); + const log: Array = []; + + Fantom.runTask(() => { + root.render(); + }); + Fantom.runTask(() => { + new ResizeObserver(entries => { + log.push(`observed ${entries[0].contentRect.width}`); + }).observe(nullthrows(ref.current)); + }); + log.length = 0; + + Fantom.runTask(() => { + Fantom.scheduleTask(() => { + log.push('next task'); + }); + nullthrows(ref.current).setNativeProps({style: {width: 50}}); + }); + + expect(log).toEqual(['observed 50', 'next task']); + }); + + describe('with a React update in the same event handler', () => { + // A discrete event makes React commit in the same task as the handler. + function renderAndClick( + onClick: (setLabel: (label: string) => void) => void, + renderChildren: (label: string) => React.Node, + ) { + const root = Fantom.createRoot(); + const containerRef = React.createRef(); + + function TestComponent() { + const [label, setLabel] = useState('first'); + return ( + onClick(setLabel)}> + {renderChildren(label)} + + ); + } + + Fantom.runTask(() => { + root.render(); + }); + Fantom.dispatchNativeEvent(nullthrows(containerRef.current), 'click'); + return root; + } + + for (const updateFirst of [false, true]) { + const order = updateFirst ? 'before' : 'after'; + test(`keeps the props when React updates another subtree ${order} the call`, () => { + const ref = React.createRef(); + const root = renderAndClick( + setLabel => { + if (updateFirst) { + setLabel('second'); + } + nullthrows(ref.current).setNativeProps({testID: 'native'}); + if (!updateFirst) { + setLabel('second'); + } + }, + label => [ + + + , + + + , + ], + ); + + expect( + root.getRenderedOutput({props: ['nativeID', 'testID']}).toJSX(), + ).toEqual( + + + + + + + + , + ); + }); + } + + test('lets React override the props', () => { + const ref = React.createRef(); + const root = renderAndClick( + setLabel => { + nullthrows(ref.current).setNativeProps({testID: 'native'}); + setLabel('second'); + }, + label => , + ); + + expect( + root.getRenderedOutput({props: ['nativeID', 'testID']}).toJSX(), + ).toEqual( + + + , + ); + }); + }); + + test('applies the props from a task that throws, and later calls', () => { + const root = Fantom.createRoot(); + const ref = React.createRef(); + renderSiblings(root, [ref]); + + expect(() => + Fantom.runTask(() => { + nullthrows(ref.current).setNativeProps({testID: 'before-throw'}); + throw new Error('Task error'); + }), + ).toThrow('Task error'); + + expect(root.getRenderedOutput({props: ['testID']}).toJSX()).toEqual( + + + , + ); + + Fantom.runTask(() => { + nullthrows(ref.current).setNativeProps({testID: 'next-task'}); + }); + + expect(root.getRenderedOutput({props: ['testID']}).toJSX()).toEqual( + + + , + ); + }); + + if (ReactNativeFeatureFlags.enableSetNativePropsBatching()) { + describe('when `enableSetNativePropsBatching` is on', () => { + test('clones each node once per task', () => { + const root = Fantom.createRoot(); + const refs = [ + React.createRef(), + React.createRef(), + ]; + renderSiblings(root, refs); + const getRevision = Fantom.createShadowNodeRevisionGetter( + nullthrows(refs[0].current), + ); + const before = nullthrows(getRevision()); + + Fantom.runTask(() => { + for (const ref of refs) { + nullthrows(ref.current).setNativeProps({testID: 'native'}); + } + }); + + // A commit per call would clone the first node again, as a sibling of + // the second. + expect(getRevision()).toBe(before + 1); + }); + }); + } +});