From 4caf9ec7a0c4b9fce6e4d6df555020e78edca3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 23 Jul 2024 14:23:03 -0700 Subject: [PATCH] Migrate CoreFeatures::enableReportEventPaintTime to new feature flags system (#45585) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45585 Changelog: [internal] Just migrates the flag to the new system. Reviewed By: sammy-SC Differential Revision: D60050005 fbshipit-source-id: 4da39446ecdb6cd86ccf7ee75a0d489764c37be6 --- .../featureflags/ReactNativeFeatureFlags.kt | 8 ++- .../ReactNativeFeatureFlagsCxxAccessor.kt | 12 +++- .../ReactNativeFeatureFlagsCxxInterop.kt | 4 +- .../ReactNativeFeatureFlagsDefaults.kt | 4 +- .../ReactNativeFeatureFlagsLocalAccessor.kt | 13 +++- .../ReactNativeFeatureFlagsProvider.kt | 4 +- .../JReactNativeFeatureFlagsCxxInterop.cpp | 16 ++++- .../JReactNativeFeatureFlagsCxxInterop.h | 5 +- .../featureflags/ReactNativeFeatureFlags.cpp | 6 +- .../featureflags/ReactNativeFeatureFlags.h | 7 +- .../ReactNativeFeatureFlagsAccessor.cpp | 64 ++++++++++++------- .../ReactNativeFeatureFlagsAccessor.h | 6 +- .../ReactNativeFeatureFlagsDefaults.h | 6 +- .../ReactNativeFeatureFlagsProvider.h | 3 +- .../NativeReactNativeFeatureFlags.cpp | 7 +- .../NativeReactNativeFeatureFlags.h | 4 +- .../renderer/observers/events/CMakeLists.txt | 1 + .../events/EventPerformanceLogger.cpp | 5 +- .../react/renderer/scheduler/Scheduler.cpp | 5 +- .../ReactCommon/react/utils/CoreFeatures.cpp | 1 - .../ReactCommon/react/utils/CoreFeatures.h | 4 -- .../ReactNativeFeatureFlags.config.js | 5 ++ .../featureflags/ReactNativeFeatureFlags.js | 7 +- .../specs/NativeReactNativeFeatureFlags.js | 3 +- 24 files changed, 148 insertions(+), 52 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index 73e48c14e05..ace6da52e8b 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<<4a2baeeff0b03f07a259028cf4446455>> + * @generated SignedSource<> */ /** @@ -112,6 +112,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enablePropsUpdateReconciliationAndroid(): Boolean = accessor.enablePropsUpdateReconciliationAndroid() + /** + * Report paint time inside the Event Timing API implementation (PerformanceObserver). + */ + @JvmStatic + public fun enableReportEventPaintTime(): Boolean = accessor.enableReportEventPaintTime() + /** * Dispatches state updates synchronously in Fabric (e.g.: updates the scroll position in the shadow tree synchronously from the main thread). */ 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 f65acaa57ad..0b3ceebbcf2 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<<7fbe53bfb2b06cdae8b1590c9131edbb>> + * @generated SignedSource<<2a8d5ca8a0ac46b4d3177cb8b12ad7ac>> */ /** @@ -34,6 +34,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso private var enableLongTaskAPICache: Boolean? = null private var enableMicrotasksCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null + private var enableReportEventPaintTimeCache: Boolean? = null private var enableSynchronousStateUpdatesCache: Boolean? = null private var enableUIConsistencyCache: Boolean? = null private var excludeYogaFromRawPropsCache: Boolean? = null @@ -183,6 +184,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso return cached } + override fun enableReportEventPaintTime(): Boolean { + var cached = enableReportEventPaintTimeCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableReportEventPaintTime() + enableReportEventPaintTimeCache = cached + } + return cached + } + override fun enableSynchronousStateUpdates(): Boolean { var cached = enableSynchronousStateUpdatesCache 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 c19a1f89cd4..48394927c53 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<> + * @generated SignedSource<> */ /** @@ -56,6 +56,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enablePropsUpdateReconciliationAndroid(): Boolean + @DoNotStrip @JvmStatic public external fun enableReportEventPaintTime(): Boolean + @DoNotStrip @JvmStatic public external fun enableSynchronousStateUpdates(): Boolean @DoNotStrip @JvmStatic public external fun enableUIConsistency(): 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 638e594f5d9..c229e8d69b9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -51,6 +51,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enablePropsUpdateReconciliationAndroid(): Boolean = false + override fun enableReportEventPaintTime(): Boolean = false + override fun enableSynchronousStateUpdates(): Boolean = false override fun enableUIConsistency(): 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 32d4d580023..6575e5f9146 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<> + * @generated SignedSource<<82f6d4eda4011bee81810af366f5d677>> */ /** @@ -38,6 +38,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces private var enableLongTaskAPICache: Boolean? = null private var enableMicrotasksCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null + private var enableReportEventPaintTimeCache: Boolean? = null private var enableSynchronousStateUpdatesCache: Boolean? = null private var enableUIConsistencyCache: Boolean? = null private var excludeYogaFromRawPropsCache: Boolean? = null @@ -201,6 +202,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableReportEventPaintTime(): Boolean { + var cached = enableReportEventPaintTimeCache + if (cached == null) { + cached = currentProvider.enableReportEventPaintTime() + accessedFeatureFlags.add("enableReportEventPaintTime") + enableReportEventPaintTimeCache = cached + } + return cached + } + override fun enableSynchronousStateUpdates(): Boolean { var cached = enableSynchronousStateUpdatesCache 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 07d5e57812b..0184ee6e577 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<> + * @generated SignedSource<> */ /** @@ -51,6 +51,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enablePropsUpdateReconciliationAndroid(): Boolean + @DoNotStrip public fun enableReportEventPaintTime(): Boolean + @DoNotStrip public fun enableSynchronousStateUpdates(): Boolean @DoNotStrip public fun enableUIConsistency(): 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 1f66dca3186..5719d853bcf 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<<7671fb85b168f4eb8713fe087a9f1e31>> + * @generated SignedSource<<7c14f956fd20226acfb532d806c6eb7a>> */ /** @@ -123,6 +123,12 @@ class ReactNativeFeatureFlagsProviderHolder return method(javaProvider_); } + bool enableReportEventPaintTime() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableReportEventPaintTime"); + return method(javaProvider_); + } + bool enableSynchronousStateUpdates() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableSynchronousStateUpdates"); @@ -329,6 +335,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enablePropsUpdateReconciliationAndroid( return ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid(); } +bool JReactNativeFeatureFlagsCxxInterop::enableReportEventPaintTime( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableReportEventPaintTime(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableSynchronousStateUpdates( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableSynchronousStateUpdates(); @@ -498,6 +509,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enablePropsUpdateReconciliationAndroid", JReactNativeFeatureFlagsCxxInterop::enablePropsUpdateReconciliationAndroid), + makeNativeMethod( + "enableReportEventPaintTime", + JReactNativeFeatureFlagsCxxInterop::enableReportEventPaintTime), makeNativeMethod( "enableSynchronousStateUpdates", JReactNativeFeatureFlagsCxxInterop::enableSynchronousStateUpdates), 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 4251014e2cd..4847c7e89f5 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<<06b35c2faaf073589042046179aaf65a>> + * @generated SignedSource<> */ /** @@ -72,6 +72,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enablePropsUpdateReconciliationAndroid( facebook::jni::alias_ref); + static bool enableReportEventPaintTime( + facebook::jni::alias_ref); + static bool enableSynchronousStateUpdates( 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 ed2087d47c5..4f06af9e6da 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<<541ad52f8b28ce4f72da4ce00cc7ba0e>> + * @generated SignedSource<> */ /** @@ -77,6 +77,10 @@ bool ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid() { return getAccessor().enablePropsUpdateReconciliationAndroid(); } +bool ReactNativeFeatureFlags::enableReportEventPaintTime() { + return getAccessor().enableReportEventPaintTime(); +} + bool ReactNativeFeatureFlags::enableSynchronousStateUpdates() { return getAccessor().enableSynchronousStateUpdates(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 93c2fc39661..4fe7c6ae6f9 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<<8d5e69e5a5bab6f48008f2b68f1a3126>> + * @generated SignedSource<<55d6c0f7ab8abe8411194235ab362cd2>> */ /** @@ -107,6 +107,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enablePropsUpdateReconciliationAndroid(); + /** + * Report paint time inside the Event Timing API implementation (PerformanceObserver). + */ + RN_EXPORT static bool enableReportEventPaintTime(); + /** * Dispatches state updates synchronously in Fabric (e.g.: updates the scroll position in the shadow tree synchronously from the main thread). */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index dee2f16ea9c..875b1f3f50b 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<<3ff5c0e239af49ce69f2655e7c2ee937>> + * @generated SignedSource<> */ /** @@ -281,6 +281,24 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableReportEventPaintTime() { + auto flagValue = enableReportEventPaintTime_.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(14, "enableReportEventPaintTime"); + + flagValue = currentProvider_->enableReportEventPaintTime(); + enableReportEventPaintTime_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableSynchronousStateUpdates() { auto flagValue = enableSynchronousStateUpdates_.load(); @@ -290,7 +308,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(14, "enableSynchronousStateUpdates"); + markFlagAsAccessed(15, "enableSynchronousStateUpdates"); flagValue = currentProvider_->enableSynchronousStateUpdates(); enableSynchronousStateUpdates_ = flagValue; @@ -308,7 +326,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(15, "enableUIConsistency"); + markFlagAsAccessed(16, "enableUIConsistency"); flagValue = currentProvider_->enableUIConsistency(); enableUIConsistency_ = flagValue; @@ -326,7 +344,7 @@ bool ReactNativeFeatureFlagsAccessor::excludeYogaFromRawProps() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(16, "excludeYogaFromRawProps"); + markFlagAsAccessed(17, "excludeYogaFromRawProps"); flagValue = currentProvider_->excludeYogaFromRawProps(); excludeYogaFromRawProps_ = flagValue; @@ -344,7 +362,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(17, "fetchImagesInViewPreallocation"); + markFlagAsAccessed(18, "fetchImagesInViewPreallocation"); flagValue = currentProvider_->fetchImagesInViewPreallocation(); fetchImagesInViewPreallocation_ = flagValue; @@ -362,7 +380,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(18, "fixIncorrectScrollViewStateUpdateOnAndroid"); + markFlagAsAccessed(19, "fixIncorrectScrollViewStateUpdateOnAndroid"); flagValue = currentProvider_->fixIncorrectScrollViewStateUpdateOnAndroid(); fixIncorrectScrollViewStateUpdateOnAndroid_ = flagValue; @@ -380,7 +398,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(19, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(20, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -398,7 +416,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(20, "fixMissedFabricStateUpdatesOnAndroid"); + markFlagAsAccessed(21, "fixMissedFabricStateUpdatesOnAndroid"); flagValue = currentProvider_->fixMissedFabricStateUpdatesOnAndroid(); fixMissedFabricStateUpdatesOnAndroid_ = flagValue; @@ -416,7 +434,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(21, "forceBatchingMountItemsOnAndroid"); + markFlagAsAccessed(22, "forceBatchingMountItemsOnAndroid"); flagValue = currentProvider_->forceBatchingMountItemsOnAndroid(); forceBatchingMountItemsOnAndroid_ = flagValue; @@ -434,7 +452,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(22, "fuseboxEnabledDebug"); + markFlagAsAccessed(23, "fuseboxEnabledDebug"); flagValue = currentProvider_->fuseboxEnabledDebug(); fuseboxEnabledDebug_ = flagValue; @@ -452,7 +470,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(23, "fuseboxEnabledRelease"); + markFlagAsAccessed(24, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -470,7 +488,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(24, "initEagerTurboModulesOnNativeModulesQueueAndroid"); + markFlagAsAccessed(25, "initEagerTurboModulesOnNativeModulesQueueAndroid"); flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid(); initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue; @@ -488,7 +506,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(25, "lazyAnimationCallbacks"); + markFlagAsAccessed(26, "lazyAnimationCallbacks"); flagValue = currentProvider_->lazyAnimationCallbacks(); lazyAnimationCallbacks_ = flagValue; @@ -506,7 +524,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(26, "loadVectorDrawablesOnImages"); + markFlagAsAccessed(27, "loadVectorDrawablesOnImages"); flagValue = currentProvider_->loadVectorDrawablesOnImages(); loadVectorDrawablesOnImages_ = flagValue; @@ -524,7 +542,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(27, "setAndroidLayoutDirection"); + markFlagAsAccessed(28, "setAndroidLayoutDirection"); flagValue = currentProvider_->setAndroidLayoutDirection(); setAndroidLayoutDirection_ = flagValue; @@ -542,7 +560,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(28, "useImmediateExecutorInAndroidBridgeless"); + markFlagAsAccessed(29, "useImmediateExecutorInAndroidBridgeless"); flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless(); useImmediateExecutorInAndroidBridgeless_ = flagValue; @@ -560,7 +578,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(29, "useModernRuntimeScheduler"); + markFlagAsAccessed(30, "useModernRuntimeScheduler"); flagValue = currentProvider_->useModernRuntimeScheduler(); useModernRuntimeScheduler_ = flagValue; @@ -578,7 +596,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(30, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(31, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -596,7 +614,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(31, "useNewReactImageViewBackgroundDrawing"); + markFlagAsAccessed(32, "useNewReactImageViewBackgroundDrawing"); flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing(); useNewReactImageViewBackgroundDrawing_ = flagValue; @@ -614,7 +632,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimisedViewPreallocationOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(32, "useOptimisedViewPreallocationOnAndroid"); + markFlagAsAccessed(33, "useOptimisedViewPreallocationOnAndroid"); flagValue = currentProvider_->useOptimisedViewPreallocationOnAndroid(); useOptimisedViewPreallocationOnAndroid_ = flagValue; @@ -632,7 +650,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(33, "useRuntimeShadowNodeReferenceUpdate"); + markFlagAsAccessed(34, "useRuntimeShadowNodeReferenceUpdate"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate(); useRuntimeShadowNodeReferenceUpdate_ = flagValue; @@ -650,7 +668,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(34, "useRuntimeShadowNodeReferenceUpdateOnLayout"); + markFlagAsAccessed(35, "useRuntimeShadowNodeReferenceUpdateOnLayout"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout(); useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue; @@ -668,7 +686,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(35, "useStateAlignmentMechanism"); + markFlagAsAccessed(36, "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 2aab5e46211..c3261cb03d1 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<<8efbce21aeb4cd838f324264514b3e68>> + * @generated SignedSource<> */ /** @@ -45,6 +45,7 @@ class ReactNativeFeatureFlagsAccessor { bool enableLongTaskAPI(); bool enableMicrotasks(); bool enablePropsUpdateReconciliationAndroid(); + bool enableReportEventPaintTime(); bool enableSynchronousStateUpdates(); bool enableUIConsistency(); bool excludeYogaFromRawProps(); @@ -77,7 +78,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 36> accessedFeatureFlags_; + std::array, 37> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> allowCollapsableChildren_; @@ -93,6 +94,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> enableLongTaskAPI_; std::atomic> enableMicrotasks_; std::atomic> enablePropsUpdateReconciliationAndroid_; + std::atomic> enableReportEventPaintTime_; std::atomic> enableSynchronousStateUpdates_; std::atomic> enableUIConsistency_; std::atomic> excludeYogaFromRawProps_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index c815ee28196..d8a87d08373 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<> + * @generated SignedSource<<436dd66c962b5bd70cc574d573ddfc0a>> */ /** @@ -83,6 +83,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableReportEventPaintTime() override { + return false; + } + bool enableSynchronousStateUpdates() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index a898b67220f..8d044153ae6 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<48be14c9be6da39c4acbf449d9ec8741>> */ /** @@ -39,6 +39,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool enableLongTaskAPI() = 0; virtual bool enableMicrotasks() = 0; virtual bool enablePropsUpdateReconciliationAndroid() = 0; + virtual bool enableReportEventPaintTime() = 0; virtual bool enableSynchronousStateUpdates() = 0; virtual bool enableUIConsistency() = 0; virtual bool excludeYogaFromRawProps() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index acaa66a8c5d..4ddfea42f3f 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<> */ /** @@ -107,6 +107,11 @@ bool NativeReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid( return ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid(); } +bool NativeReactNativeFeatureFlags::enableReportEventPaintTime( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableReportEventPaintTime(); +} + bool NativeReactNativeFeatureFlags::enableSynchronousStateUpdates( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableSynchronousStateUpdates(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 0c1065fea97..ffee73a8b3b 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<> */ /** @@ -63,6 +63,8 @@ class NativeReactNativeFeatureFlags bool enablePropsUpdateReconciliationAndroid(jsi::Runtime& runtime); + bool enableReportEventPaintTime(jsi::Runtime& runtime); + bool enableSynchronousStateUpdates(jsi::Runtime& runtime); bool enableUIConsistency(jsi::Runtime& runtime); diff --git a/packages/react-native/ReactCommon/react/renderer/observers/events/CMakeLists.txt b/packages/react-native/ReactCommon/react/renderer/observers/events/CMakeLists.txt index 5c5e61f3658..83d1f3b79e0 100644 --- a/packages/react-native/ReactCommon/react/renderer/observers/events/CMakeLists.txt +++ b/packages/react-native/ReactCommon/react/renderer/observers/events/CMakeLists.txt @@ -21,5 +21,6 @@ target_include_directories(react_render_observers_events PUBLIC ${REACT_COMMON_D target_link_libraries(react_render_observers_events react_performance_timeline react_render_core + react_featureflags react_render_uimanager react_utils) diff --git a/packages/react-native/ReactCommon/react/renderer/observers/events/EventPerformanceLogger.cpp b/packages/react-native/ReactCommon/react/renderer/observers/events/EventPerformanceLogger.cpp index 95e66d16445..57f273ca1ac 100644 --- a/packages/react-native/ReactCommon/react/renderer/observers/events/EventPerformanceLogger.cpp +++ b/packages/react-native/ReactCommon/react/renderer/observers/events/EventPerformanceLogger.cpp @@ -7,6 +7,7 @@ #include "EventPerformanceLogger.h" +#include #include #include @@ -140,7 +141,7 @@ void EventPerformanceLogger::onEventProcessingEnd(EventTag tag) { auto& entry = it->second; entry.processingEndTime = timeStamp; - if (CoreFeatures::enableReportEventPaintTime) { + if (ReactNativeFeatureFlags::enableReportEventPaintTime()) { // If reporting paint time, don't send the entry just yet and wait for the // mount hook callback to be called return; @@ -162,7 +163,7 @@ void EventPerformanceLogger::onEventProcessingEnd(EventTag tag) { void EventPerformanceLogger::shadowTreeDidMount( const RootShadowNode::Shared& /*rootShadowNode*/, double mountTime) noexcept { - if (!CoreFeatures::enableReportEventPaintTime) { + if (!ReactNativeFeatureFlags::enableReportEventPaintTime()) { return; } diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 9a65c7bbf4e..3ddd7a7d0cc 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -151,10 +151,7 @@ Scheduler::Scheduler( "react_fabric:remove_outstanding_surfaces_on_destruction_ios"); #endif - CoreFeatures::enableReportEventPaintTime = reactNativeConfig_->getBool( - "rn_responsiveness_performance:enable_paint_time_reporting"); - - if (CoreFeatures::enableReportEventPaintTime) { + if (ReactNativeFeatureFlags::enableReportEventPaintTime()) { uiManager->registerMountHook(*eventPerformanceLogger_); } } diff --git a/packages/react-native/ReactCommon/react/utils/CoreFeatures.cpp b/packages/react-native/ReactCommon/react/utils/CoreFeatures.cpp index 7b59a9017e3..d1a236bc5e7 100644 --- a/packages/react-native/ReactCommon/react/utils/CoreFeatures.cpp +++ b/packages/react-native/ReactCommon/react/utils/CoreFeatures.cpp @@ -12,6 +12,5 @@ namespace facebook::react { bool CoreFeatures::enablePropIteratorSetter = false; bool CoreFeatures::enableGranularScrollViewStateUpdatesIOS = false; bool CoreFeatures::excludeYogaFromRawProps = false; -bool CoreFeatures::enableReportEventPaintTime = false; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/utils/CoreFeatures.h b/packages/react-native/ReactCommon/react/utils/CoreFeatures.h index 7e7269a6314..b053003bda3 100644 --- a/packages/react-native/ReactCommon/react/utils/CoreFeatures.h +++ b/packages/react-native/ReactCommon/react/utils/CoreFeatures.h @@ -25,10 +25,6 @@ class CoreFeatures { // When enabled, rawProps in Props will not include Yoga specific props. static bool excludeYogaFromRawProps; - - // Report paint time inside the Event Timing API implementation - // (PerformanceObserver). - static bool enableReportEventPaintTime; }; } // namespace facebook::react diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 07a40d414f3..7b6893b3693 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -103,6 +103,11 @@ const definitions: FeatureFlagDefinitions = { description: 'When enabled, Android will receive prop updates based on the differences between the last rendered shadow node and the last committed shadow node.', }, + enableReportEventPaintTime: { + defaultValue: false, + description: + 'Report paint time inside the Event Timing API implementation (PerformanceObserver).', + }, enableSynchronousStateUpdates: { defaultValue: false, description: diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 9acb453ac20..ebbdb13b3a0 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<<1f55fc80f2d20514a341988b4f938ac5>> + * @generated SignedSource<> * @flow strict-local */ @@ -57,6 +57,7 @@ export type ReactNativeFeatureFlags = { enableLongTaskAPI: Getter, enableMicrotasks: Getter, enablePropsUpdateReconciliationAndroid: Getter, + enableReportEventPaintTime: Getter, enableSynchronousStateUpdates: Getter, enableUIConsistency: Getter, excludeYogaFromRawProps: Getter, @@ -192,6 +193,10 @@ export const enableMicrotasks: Getter = createNativeFlagGetter('enableM * When enabled, Android will receive prop updates based on the differences between the last rendered shadow node and the last committed shadow node. */ export const enablePropsUpdateReconciliationAndroid: Getter = createNativeFlagGetter('enablePropsUpdateReconciliationAndroid', false); +/** + * Report paint time inside the Event Timing API implementation (PerformanceObserver). + */ +export const enableReportEventPaintTime: Getter = createNativeFlagGetter('enableReportEventPaintTime', false); /** * Dispatches state updates synchronously in Fabric (e.g.: updates the scroll position in the shadow tree synchronously from the main thread). */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index eac76643f5c..39090d74168 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<<0ee6343505e52cde7930a31ab5c8218a>> + * @generated SignedSource<> * @flow strict-local */ @@ -37,6 +37,7 @@ export interface Spec extends TurboModule { +enableLongTaskAPI?: () => boolean; +enableMicrotasks?: () => boolean; +enablePropsUpdateReconciliationAndroid?: () => boolean; + +enableReportEventPaintTime?: () => boolean; +enableSynchronousStateUpdates?: () => boolean; +enableUIConsistency?: () => boolean; +excludeYogaFromRawProps?: () => boolean;