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 97aff6c2a47..5ea74ae63e1 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<<298c05e5b7384384b5fcdd851a298738>> + * @generated SignedSource<<2dda5cec029bcd7bb62e428f4b4557f5>> */ /** @@ -52,6 +52,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun batchRenderingUpdatesInEventLoop(): Boolean = accessor.batchRenderingUpdatesInEventLoop() + /** + * When enabled, insert of views on Android will be moved from the beginning of the IntBufferBatchMountItem to be after layout updates. + */ + @JvmStatic + public fun changeOrderOfMountingInstructionsOnAndroid(): Boolean = accessor.changeOrderOfMountingInstructionsOnAndroid() + /** * When enabled, ReactInstanceManager will clean up Fabric surfaces on destroy(). */ 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 5f29fe4e694..55653f44df5 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<<5eff2e46b755c3d363ec5635831bf492>> + * @generated SignedSource<<125b4c5029a2f7f3d10ecd6f5382c46c>> */ /** @@ -24,6 +24,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso private var allowCollapsableChildrenCache: Boolean? = null private var allowRecursiveCommitsWithSynchronousMountOnAndroidCache: Boolean? = null private var batchRenderingUpdatesInEventLoopCache: Boolean? = null + private var changeOrderOfMountingInstructionsOnAndroidCache: Boolean? = null private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null private var enableCleanTextInputYogaNodeCache: Boolean? = null @@ -87,6 +88,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso return cached } + override fun changeOrderOfMountingInstructionsOnAndroid(): Boolean { + var cached = changeOrderOfMountingInstructionsOnAndroidCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.changeOrderOfMountingInstructionsOnAndroid() + changeOrderOfMountingInstructionsOnAndroidCache = cached + } + return cached + } + override fun destroyFabricSurfacesInReactInstanceManager(): Boolean { var cached = destroyFabricSurfacesInReactInstanceManagerCache 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 cbda60e53f9..548cdbd76c9 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<<29a946df7b0cbe24a476873adcf574ee>> + * @generated SignedSource<<15d521183f0efa93c87155890d88cf72>> */ /** @@ -36,6 +36,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun batchRenderingUpdatesInEventLoop(): Boolean + @DoNotStrip @JvmStatic public external fun changeOrderOfMountingInstructionsOnAndroid(): Boolean + @DoNotStrip @JvmStatic public external fun destroyFabricSurfacesInReactInstanceManager(): Boolean @DoNotStrip @JvmStatic public external fun enableAlignItemsBaselineOnFabricIOS(): 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 39947455ce8..5476a51d7a1 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<<0fa4e9e2c5f3d96f729f5822783ce86f>> + * @generated SignedSource<<1f8a830a3dec9278f4cd387bb706864e>> */ /** @@ -31,6 +31,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun batchRenderingUpdatesInEventLoop(): Boolean = false + override fun changeOrderOfMountingInstructionsOnAndroid(): Boolean = false + override fun destroyFabricSurfacesInReactInstanceManager(): Boolean = false override fun enableAlignItemsBaselineOnFabricIOS(): Boolean = true 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 76d17902730..a75971522e7 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<<105ab999064160753e636f86edfc00a2>> + * @generated SignedSource<<0b90fde158e97c4cad711c3ab832f067>> */ /** @@ -28,6 +28,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces private var allowCollapsableChildrenCache: Boolean? = null private var allowRecursiveCommitsWithSynchronousMountOnAndroidCache: Boolean? = null private var batchRenderingUpdatesInEventLoopCache: Boolean? = null + private var changeOrderOfMountingInstructionsOnAndroidCache: Boolean? = null private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null private var enableCleanTextInputYogaNodeCache: Boolean? = null @@ -95,6 +96,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun changeOrderOfMountingInstructionsOnAndroid(): Boolean { + var cached = changeOrderOfMountingInstructionsOnAndroidCache + if (cached == null) { + cached = currentProvider.changeOrderOfMountingInstructionsOnAndroid() + accessedFeatureFlags.add("changeOrderOfMountingInstructionsOnAndroid") + changeOrderOfMountingInstructionsOnAndroidCache = cached + } + return cached + } + override fun destroyFabricSurfacesInReactInstanceManager(): Boolean { var cached = destroyFabricSurfacesInReactInstanceManagerCache 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 6f7745a5f7a..a9ed3b088ed 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<<38e08cba4070759027d73c74c0f26e01>> + * @generated SignedSource<<55fa16b3333fb8e2820a078c68850f91>> */ /** @@ -31,6 +31,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun batchRenderingUpdatesInEventLoop(): Boolean + @DoNotStrip public fun changeOrderOfMountingInstructionsOnAndroid(): Boolean + @DoNotStrip public fun destroyFabricSurfacesInReactInstanceManager(): Boolean @DoNotStrip public fun enableAlignItemsBaselineOnFabricIOS(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp index c3645749abc..7401f8ad813 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp @@ -487,10 +487,18 @@ void FabricMountingManager::executeMount( int objBufferPosition = 0; int prevMountItemType = -1; jint temp[8]; + // Fill in CREATE instructions. for (int i = 0; i < cppCommonMountItems.size(); i++) { const auto& mountItem = cppCommonMountItems[i]; const auto& mountItemType = mountItem.type; + if (ReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid() && + mountItemType != CppMountItem::Type::Create) { + prevMountItemType = -1; + // Skip all mount items except Create. + continue; + } + // Get type here, and count forward how many items of this type are in a // row. Write preamble to any common type here. if (prevMountItemType != mountItemType) { @@ -510,7 +518,6 @@ void FabricMountingManager::executeMount( } prevMountItemType = mountItemType; - // TODO: multi-create, multi-insert, etc if (mountItemType == CppMountItem::Type::Create) { auto componentName = getPlatformComponentName(mountItem.newChildShadowView); @@ -557,9 +564,10 @@ void FabricMountingManager::executeMount( env->SetIntArrayRegion(intBufferArray, intBufferPosition, 3, temp); intBufferPosition += 3; } else { - LOG(ERROR) << "Unexpected CppMountItem type"; + LOG(ERROR) << "Unexpected CppMountItem type: " << mountItemType; } } + if (!cppUpdatePropsMountItems.empty()) { writeIntBufferTypePreamble( CppMountItem::Type::UpdateProps, @@ -719,6 +727,55 @@ void FabricMountingManager::executeMount( } } + if (ReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid()) { + // Fill in all other instructions. + prevMountItemType = -1; + for (int i = 0; i < cppCommonMountItems.size(); i++) { + const auto& mountItem = cppCommonMountItems[i]; + const auto& mountItemType = mountItem.type; + + if (mountItemType == CppMountItem::Type::Create) { + prevMountItemType = -1; + continue; + } + + // Get type here, and count forward how many items of this type are in + // row. Write preamble to any common type here. + if (prevMountItemType != mountItemType) { + int numSameItemTypes = 1; + for (int j = i + 1; j < cppCommonMountItems.size() && + cppCommonMountItems[j].type == mountItemType; + j++) { + numSameItemTypes++; + } + + writeIntBufferTypePreamble( + mountItemType, + numSameItemTypes, + env, + intBufferArray, + intBufferPosition); + } + prevMountItemType = mountItemType; + + if (mountItemType == CppMountItem::Type::Insert) { + temp[0] = mountItem.newChildShadowView.tag; + temp[1] = mountItem.parentShadowView.tag; + temp[2] = mountItem.index; + env->SetIntArrayRegion(intBufferArray, intBufferPosition, 3, temp); + intBufferPosition += 3; + } else if (mountItemType == CppMountItem::Remove) { + temp[0] = mountItem.oldChildShadowView.tag; + temp[1] = mountItem.parentShadowView.tag; + temp[2] = mountItem.index; + env->SetIntArrayRegion(intBufferArray, intBufferPosition, 3, temp); + intBufferPosition += 3; + } else { + LOG(ERROR) << "Unexpected CppMountItem type: " << mountItemType; + } + } + } + // Write deletes last - so that all prop updates, etc, for the tag in the same // batch don't fail. Without additional machinery, moving deletes here // requires that the differ never produces "DELETE...CREATE" in that order for 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 b3a487aa7e0..25dc5d54ae3 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<<2e96ad47b2024e6461c46855e473b3d2>> + * @generated SignedSource<<0be20439a937a322afa27a9c935a98ad>> */ /** @@ -63,6 +63,12 @@ class ReactNativeFeatureFlagsProviderHolder return method(javaProvider_); } + bool changeOrderOfMountingInstructionsOnAndroid() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("changeOrderOfMountingInstructionsOnAndroid"); + return method(javaProvider_); + } + bool destroyFabricSurfacesInReactInstanceManager() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("destroyFabricSurfacesInReactInstanceManager"); @@ -243,6 +249,11 @@ bool JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop( return ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop(); } +bool JReactNativeFeatureFlagsCxxInterop::changeOrderOfMountingInstructionsOnAndroid( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid(); +} + bool JReactNativeFeatureFlagsCxxInterop::destroyFabricSurfacesInReactInstanceManager( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::destroyFabricSurfacesInReactInstanceManager(); @@ -402,6 +413,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "batchRenderingUpdatesInEventLoop", JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop), + makeNativeMethod( + "changeOrderOfMountingInstructionsOnAndroid", + JReactNativeFeatureFlagsCxxInterop::changeOrderOfMountingInstructionsOnAndroid), makeNativeMethod( "destroyFabricSurfacesInReactInstanceManager", JReactNativeFeatureFlagsCxxInterop::destroyFabricSurfacesInReactInstanceManager), 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 b366543051c..bd890fdbbc7 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<> + * @generated SignedSource<<5771674cf23f066fb2c7a493441e9967>> */ /** @@ -42,6 +42,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool batchRenderingUpdatesInEventLoop( facebook::jni::alias_ref); + static bool changeOrderOfMountingInstructionsOnAndroid( + facebook::jni::alias_ref); + static bool destroyFabricSurfacesInReactInstanceManager( 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 9cbb22ffdbc..22034069e7c 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<<84bc0f2c1750310a2062ba947df45104>> + * @generated SignedSource<<0f673fbed5f3cce13f7a42a8817ed404>> */ /** @@ -37,6 +37,10 @@ bool ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop() { return getAccessor().batchRenderingUpdatesInEventLoop(); } +bool ReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid() { + return getAccessor().changeOrderOfMountingInstructionsOnAndroid(); +} + bool ReactNativeFeatureFlags::destroyFabricSurfacesInReactInstanceManager() { return getAccessor().destroyFabricSurfacesInReactInstanceManager(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 0d1e0008698..47350ccbed9 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<> */ /** @@ -57,6 +57,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool batchRenderingUpdatesInEventLoop(); + /** + * When enabled, insert of views on Android will be moved from the beginning of the IntBufferBatchMountItem to be after layout updates. + */ + RN_EXPORT static bool changeOrderOfMountingInstructionsOnAndroid(); + /** * When enabled, ReactInstanceManager will clean up Fabric surfaces on destroy(). */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index ec73141d2c9..ed6456c75fb 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<<617b5fe964a8e57aec09d92d686b7acd>> + * @generated SignedSource<<1ee6db4bee3b22c31d5f70785ea9e91a>> */ /** @@ -101,6 +101,24 @@ bool ReactNativeFeatureFlagsAccessor::batchRenderingUpdatesInEventLoop() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::changeOrderOfMountingInstructionsOnAndroid() { + auto flagValue = changeOrderOfMountingInstructionsOnAndroid_.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(4, "changeOrderOfMountingInstructionsOnAndroid"); + + flagValue = currentProvider_->changeOrderOfMountingInstructionsOnAndroid(); + changeOrderOfMountingInstructionsOnAndroid_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::destroyFabricSurfacesInReactInstanceManager() { auto flagValue = destroyFabricSurfacesInReactInstanceManager_.load(); @@ -110,7 +128,7 @@ bool ReactNativeFeatureFlagsAccessor::destroyFabricSurfacesInReactInstanceManage // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(4, "destroyFabricSurfacesInReactInstanceManager"); + markFlagAsAccessed(5, "destroyFabricSurfacesInReactInstanceManager"); flagValue = currentProvider_->destroyFabricSurfacesInReactInstanceManager(); destroyFabricSurfacesInReactInstanceManager_ = flagValue; @@ -128,7 +146,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAlignItemsBaselineOnFabricIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(5, "enableAlignItemsBaselineOnFabricIOS"); + markFlagAsAccessed(6, "enableAlignItemsBaselineOnFabricIOS"); flagValue = currentProvider_->enableAlignItemsBaselineOnFabricIOS(); enableAlignItemsBaselineOnFabricIOS_ = flagValue; @@ -146,7 +164,7 @@ bool ReactNativeFeatureFlagsAccessor::enableCleanTextInputYogaNode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(6, "enableCleanTextInputYogaNode"); + markFlagAsAccessed(7, "enableCleanTextInputYogaNode"); flagValue = currentProvider_->enableCleanTextInputYogaNode(); enableCleanTextInputYogaNode_ = flagValue; @@ -164,7 +182,7 @@ bool ReactNativeFeatureFlagsAccessor::enableGranularShadowTreeStateReconciliatio // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(7, "enableGranularShadowTreeStateReconciliation"); + markFlagAsAccessed(8, "enableGranularShadowTreeStateReconciliation"); flagValue = currentProvider_->enableGranularShadowTreeStateReconciliation(); enableGranularShadowTreeStateReconciliation_ = flagValue; @@ -182,7 +200,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMicrotasks() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(8, "enableMicrotasks"); + markFlagAsAccessed(9, "enableMicrotasks"); flagValue = currentProvider_->enableMicrotasks(); enableMicrotasks_ = flagValue; @@ -200,7 +218,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(9, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(10, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -218,7 +236,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSynchronousStateUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(10, "enableSynchronousStateUpdates"); + markFlagAsAccessed(11, "enableSynchronousStateUpdates"); flagValue = currentProvider_->enableSynchronousStateUpdates(); enableSynchronousStateUpdates_ = flagValue; @@ -236,7 +254,7 @@ bool ReactNativeFeatureFlagsAccessor::enableUIConsistency() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(11, "enableUIConsistency"); + markFlagAsAccessed(12, "enableUIConsistency"); flagValue = currentProvider_->enableUIConsistency(); enableUIConsistency_ = flagValue; @@ -254,7 +272,7 @@ bool ReactNativeFeatureFlagsAccessor::fetchImagesInViewPreallocation() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(12, "fetchImagesInViewPreallocation"); + markFlagAsAccessed(13, "fetchImagesInViewPreallocation"); flagValue = currentProvider_->fetchImagesInViewPreallocation(); fetchImagesInViewPreallocation_ = flagValue; @@ -272,7 +290,7 @@ bool ReactNativeFeatureFlagsAccessor::fixIncorrectScrollViewStateUpdateOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(13, "fixIncorrectScrollViewStateUpdateOnAndroid"); + markFlagAsAccessed(14, "fixIncorrectScrollViewStateUpdateOnAndroid"); flagValue = currentProvider_->fixIncorrectScrollViewStateUpdateOnAndroid(); fixIncorrectScrollViewStateUpdateOnAndroid_ = flagValue; @@ -290,7 +308,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(14, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(15, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -308,7 +326,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMissedFabricStateUpdatesOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(15, "fixMissedFabricStateUpdatesOnAndroid"); + markFlagAsAccessed(16, "fixMissedFabricStateUpdatesOnAndroid"); flagValue = currentProvider_->fixMissedFabricStateUpdatesOnAndroid(); fixMissedFabricStateUpdatesOnAndroid_ = flagValue; @@ -326,7 +344,7 @@ bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(16, "forceBatchingMountItemsOnAndroid"); + markFlagAsAccessed(17, "forceBatchingMountItemsOnAndroid"); flagValue = currentProvider_->forceBatchingMountItemsOnAndroid(); forceBatchingMountItemsOnAndroid_ = flagValue; @@ -344,7 +362,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledDebug() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(17, "fuseboxEnabledDebug"); + markFlagAsAccessed(18, "fuseboxEnabledDebug"); flagValue = currentProvider_->fuseboxEnabledDebug(); fuseboxEnabledDebug_ = flagValue; @@ -362,7 +380,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(18, "fuseboxEnabledRelease"); + markFlagAsAccessed(19, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -380,7 +398,7 @@ bool ReactNativeFeatureFlagsAccessor::initEagerTurboModulesOnNativeModulesQueueA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(19, "initEagerTurboModulesOnNativeModulesQueueAndroid"); + markFlagAsAccessed(20, "initEagerTurboModulesOnNativeModulesQueueAndroid"); flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid(); initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue; @@ -398,7 +416,7 @@ bool ReactNativeFeatureFlagsAccessor::lazyAnimationCallbacks() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(20, "lazyAnimationCallbacks"); + markFlagAsAccessed(21, "lazyAnimationCallbacks"); flagValue = currentProvider_->lazyAnimationCallbacks(); lazyAnimationCallbacks_ = flagValue; @@ -416,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::loadVectorDrawablesOnImages() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(21, "loadVectorDrawablesOnImages"); + markFlagAsAccessed(22, "loadVectorDrawablesOnImages"); flagValue = currentProvider_->loadVectorDrawablesOnImages(); loadVectorDrawablesOnImages_ = flagValue; @@ -434,7 +452,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(22, "setAndroidLayoutDirection"); + markFlagAsAccessed(23, "setAndroidLayoutDirection"); flagValue = currentProvider_->setAndroidLayoutDirection(); setAndroidLayoutDirection_ = flagValue; @@ -452,7 +470,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(23, "useImmediateExecutorInAndroidBridgeless"); + markFlagAsAccessed(24, "useImmediateExecutorInAndroidBridgeless"); flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless(); useImmediateExecutorInAndroidBridgeless_ = flagValue; @@ -470,7 +488,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(24, "useModernRuntimeScheduler"); + markFlagAsAccessed(25, "useModernRuntimeScheduler"); flagValue = currentProvider_->useModernRuntimeScheduler(); useModernRuntimeScheduler_ = flagValue; @@ -488,7 +506,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(25, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(26, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -506,7 +524,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(26, "useNewReactImageViewBackgroundDrawing"); + markFlagAsAccessed(27, "useNewReactImageViewBackgroundDrawing"); flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing(); useNewReactImageViewBackgroundDrawing_ = flagValue; @@ -524,7 +542,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(27, "useRuntimeShadowNodeReferenceUpdate"); + markFlagAsAccessed(28, "useRuntimeShadowNodeReferenceUpdate"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate(); useRuntimeShadowNodeReferenceUpdate_ = flagValue; @@ -542,7 +560,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(28, "useRuntimeShadowNodeReferenceUpdateOnLayout"); + markFlagAsAccessed(29, "useRuntimeShadowNodeReferenceUpdateOnLayout"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout(); useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue; @@ -560,7 +578,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(29, "useStateAlignmentMechanism"); + markFlagAsAccessed(30, "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 1e58a331aa8..54fb1b5856a 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<<4a5a507ce51e3058803ce2237f482dc4>> + * @generated SignedSource<<6c2bca1240818fc2c13b76943f9954d7>> */ /** @@ -35,6 +35,7 @@ class ReactNativeFeatureFlagsAccessor { bool allowCollapsableChildren(); bool allowRecursiveCommitsWithSynchronousMountOnAndroid(); bool batchRenderingUpdatesInEventLoop(); + bool changeOrderOfMountingInstructionsOnAndroid(); bool destroyFabricSurfacesInReactInstanceManager(); bool enableAlignItemsBaselineOnFabricIOS(); bool enableCleanTextInputYogaNode(); @@ -71,12 +72,13 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 30> accessedFeatureFlags_; + std::array, 31> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> allowCollapsableChildren_; std::atomic> allowRecursiveCommitsWithSynchronousMountOnAndroid_; std::atomic> batchRenderingUpdatesInEventLoop_; + std::atomic> changeOrderOfMountingInstructionsOnAndroid_; std::atomic> destroyFabricSurfacesInReactInstanceManager_; std::atomic> enableAlignItemsBaselineOnFabricIOS_; std::atomic> enableCleanTextInputYogaNode_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 4e9894c62ee..fc279a864d7 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<<4eb00950b76e497061d735f7cff04c05>> + * @generated SignedSource<> */ /** @@ -43,6 +43,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool changeOrderOfMountingInstructionsOnAndroid() override { + return false; + } + bool destroyFabricSurfacesInReactInstanceManager() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 3d0ce51080e..313aecdb297 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<<62aabd2b094847e3165f0127720cd38e>> + * @generated SignedSource<> */ /** @@ -29,6 +29,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool allowCollapsableChildren() = 0; virtual bool allowRecursiveCommitsWithSynchronousMountOnAndroid() = 0; virtual bool batchRenderingUpdatesInEventLoop() = 0; + virtual bool changeOrderOfMountingInstructionsOnAndroid() = 0; virtual bool destroyFabricSurfacesInReactInstanceManager() = 0; virtual bool enableAlignItemsBaselineOnFabricIOS() = 0; virtual bool enableCleanTextInputYogaNode() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 0f2e726d675..59d57f081af 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<<8458b6146882bfab11157e94eaaf9967>> */ /** @@ -57,6 +57,11 @@ bool NativeReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop( return ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop(); } +bool NativeReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::changeOrderOfMountingInstructionsOnAndroid(); +} + bool NativeReactNativeFeatureFlags::destroyFabricSurfacesInReactInstanceManager( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::destroyFabricSurfacesInReactInstanceManager(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index b1071951697..f22e5be46c2 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<<8710006663b0aff28f447405b26562dd>> + * @generated SignedSource<> */ /** @@ -43,6 +43,8 @@ class NativeReactNativeFeatureFlags bool batchRenderingUpdatesInEventLoop(jsi::Runtime& runtime); + bool changeOrderOfMountingInstructionsOnAndroid(jsi::Runtime& runtime); + bool destroyFabricSurfacesInReactInstanceManager(jsi::Runtime& runtime); bool enableAlignItemsBaselineOnFabricIOS(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 7945be543c6..50d1e8e7efd 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -54,6 +54,11 @@ const definitions: FeatureFlagDefinitions = { description: 'When enabled, the RuntimeScheduler processing the event loop will batch all rendering updates and dispatch them together at the end of each iteration of the loop.', }, + changeOrderOfMountingInstructionsOnAndroid: { + defaultValue: false, + description: + 'When enabled, insert of views on Android will be moved from the beginning of the IntBufferBatchMountItem to be after layout updates.', + }, destroyFabricSurfacesInReactInstanceManager: { defaultValue: false, description: diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 071495244c1..d4c4fb03c7d 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<<55c6569e1732443a2ad13c9b5f158462>> + * @generated SignedSource<<443034310c104784714bb59761335f77>> * @flow strict-local */ @@ -47,6 +47,7 @@ export type ReactNativeFeatureFlags = { allowCollapsableChildren: Getter, allowRecursiveCommitsWithSynchronousMountOnAndroid: Getter, batchRenderingUpdatesInEventLoop: Getter, + changeOrderOfMountingInstructionsOnAndroid: Getter, destroyFabricSurfacesInReactInstanceManager: Getter, enableAlignItemsBaselineOnFabricIOS: Getter, enableCleanTextInputYogaNode: Getter, @@ -146,6 +147,10 @@ export const allowRecursiveCommitsWithSynchronousMountOnAndroid: Getter * When enabled, the RuntimeScheduler processing the event loop will batch all rendering updates and dispatch them together at the end of each iteration of the loop. */ export const batchRenderingUpdatesInEventLoop: Getter = createNativeFlagGetter('batchRenderingUpdatesInEventLoop', false); +/** + * When enabled, insert of views on Android will be moved from the beginning of the IntBufferBatchMountItem to be after layout updates. + */ +export const changeOrderOfMountingInstructionsOnAndroid: Getter = createNativeFlagGetter('changeOrderOfMountingInstructionsOnAndroid', false); /** * When enabled, ReactInstanceManager will clean up Fabric surfaces on destroy(). */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index bc0d0547f66..54c1b385663 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<<19718453dfde482545a2313ca74a96ce>> * @flow strict-local */ @@ -27,6 +27,7 @@ export interface Spec extends TurboModule { +allowCollapsableChildren?: () => boolean; +allowRecursiveCommitsWithSynchronousMountOnAndroid?: () => boolean; +batchRenderingUpdatesInEventLoop?: () => boolean; + +changeOrderOfMountingInstructionsOnAndroid?: () => boolean; +destroyFabricSurfacesInReactInstanceManager?: () => boolean; +enableAlignItemsBaselineOnFabricIOS?: () => boolean; +enableCleanTextInputYogaNode?: () => boolean;