From 9682967a09a8c5f7fdb7fe903666b56bd371652a Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 26 Aug 2026 02:10:37 -0700 Subject: [PATCH] Remove enableSchedulerDelegateInvalidation feature flag and guard (#58138) Summary: Pull Request resolved: https://github.com/react/react-native/pull/58138 `enableSchedulerDelegateInvalidation` gated a defensive invalidation token in `Scheduler`: a `shared_ptr>` captured into every rendering-update lambda, flipped on delegate swap and on `Scheduler` destruction, so a lambda that outlived its captured raw delegate pointer would no-op instead of dereferencing freed memory. We are not keeping it. The dominant path into that race - a pending rendering update draining after an uncaught error tore down the delegate - is now closed upstream in `RuntimeScheduler_Modern::handleTaskError`, which clears the pending task and rendering-update queues before the host error handler runs. That leaves the token as a second mechanism guarding an already-closed window, at the cost of an atomic allocation per delegate swap and a branch in every deferred rendering update. So the flag and the guard both go: the token, its reallocation in `setDelegate`, the destructor flip, and the per-lambda `guardEnabled` capture are all removed, returning `setDelegate` to a plain assignment. The test suite keeps its coverage of the underlying race - teardown via both `uiManagerDidFinishTransaction` and `uiManagerDidDispatchCommand`, plus the assertion that surface unregistration alone does not drain pending updates - now exercising the queue-clearing behaviour that actually closes it. The two tests that differed only in the flag's value collapse into one. One window is genuinely left open, and is now pinned by a new death test: a delegate dropped and destroyed with no error involved never reaches `handleTaskError`, so nothing clears the queue and the drained lambda dereferences freed memory. Closing that properly needs a runtime-scheduler-level shutdown signal rather than a per-`Scheduler` token. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D117328638 fbshipit-source-id: d01769dc269c420482b8271576c2332bd28ab116 --- .../featureflags/ReactNativeFeatureFlags.kt | 8 +- .../ReactNativeFeatureFlagsCxxAccessor.kt | 12 +- .../ReactNativeFeatureFlagsCxxInterop.kt | 4 +- .../ReactNativeFeatureFlagsDefaults.kt | 4 +- .../ReactNativeFeatureFlagsLocalAccessor.kt | 13 +- ...agsOverrides_RNOSS_Experimental_Android.kt | 4 +- .../ReactNativeFeatureFlagsProvider.kt | 4 +- .../JReactNativeFeatureFlagsCxxInterop.cpp | 16 +-- .../JReactNativeFeatureFlagsCxxInterop.h | 5 +- .../featureflags/ReactNativeFeatureFlags.cpp | 6 +- .../featureflags/ReactNativeFeatureFlags.h | 7 +- .../ReactNativeFeatureFlagsAccessor.cpp | 104 +++++++--------- .../ReactNativeFeatureFlagsAccessor.h | 6 +- .../ReactNativeFeatureFlagsDefaults.h | 6 +- .../ReactNativeFeatureFlagsDynamicProvider.h | 11 +- ...tiveFeatureFlagsOverridesOSSExperimental.h | 6 +- .../ReactNativeFeatureFlagsProvider.h | 3 +- .../NativeReactNativeFeatureFlags.cpp | 7 +- .../NativeReactNativeFeatureFlags.h | 4 +- .../react/renderer/scheduler/Scheduler.cpp | 46 +------ .../react/renderer/scheduler/Scheduler.h | 5 - .../SchedulerDelegateInvalidationTest.cpp | 116 ++++++------------ .../ReactNativeFeatureFlags.config.js | 11 -- .../featureflags/ReactNativeFeatureFlags.js | 7 +- .../specs/NativeReactNativeFeatureFlags.js | 3 +- 25 files changed, 102 insertions(+), 316 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 f81d9ded484..5024fe15a31 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<<59766885e05931a728d63cec89fd6103>> + * @generated SignedSource<> */ /** @@ -288,12 +288,6 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableResizeObserverByDefault(): Boolean = accessor.enableResizeObserverByDefault() - /** - * Gates a defensive guard around Scheduler::uiManagerDidDispatchCommand and uiManagerDidFinishTransaction that prevents queued rendering-update lambdas from dereferencing the SchedulerDelegate after it has been destroyed (use-after-free). - */ - @JvmStatic - public fun enableSchedulerDelegateInvalidation(): Boolean = accessor.enableSchedulerDelegateInvalidation() - /** * 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 4fafbc5781b..03b90ae5e4e 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<<0bfeba3d07af6fade47b24974a80a592>> */ /** @@ -63,7 +63,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var enablePreparedTextLayoutCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null private var enableResizeObserverByDefaultCache: Boolean? = null - private var enableSchedulerDelegateInvalidationCache: Boolean? = null private var enableSwiftUIBasedFiltersCache: Boolean? = null private var enableViewCullingCache: Boolean? = null private var enableViewRecyclingCache: Boolean? = null @@ -494,15 +493,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } - override fun enableSchedulerDelegateInvalidation(): Boolean { - var cached = enableSchedulerDelegateInvalidationCache - if (cached == null) { - cached = ReactNativeFeatureFlagsCxxInterop.enableSchedulerDelegateInvalidation() - enableSchedulerDelegateInvalidationCache = 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 094c9bc10b0..ad874487ab7 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<> */ /** @@ -114,8 +114,6 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableResizeObserverByDefault(): Boolean - @DoNotStrip @JvmStatic public external fun enableSchedulerDelegateInvalidation(): 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 db9a497ddb2..0ca4d5524bf 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<> */ /** @@ -109,8 +109,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableResizeObserverByDefault(): Boolean = false - override fun enableSchedulerDelegateInvalidation(): 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 a8b593b842d..dab5705e7e4 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<<2365c1d552f84ca44c789ced558679f5>> + * @generated SignedSource<<3605df96fad767e3ec3957d7305ef926>> */ /** @@ -67,7 +67,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var enablePreparedTextLayoutCache: Boolean? = null private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null private var enableResizeObserverByDefaultCache: Boolean? = null - private var enableSchedulerDelegateInvalidationCache: Boolean? = null private var enableSwiftUIBasedFiltersCache: Boolean? = null private var enableViewCullingCache: Boolean? = null private var enableViewRecyclingCache: Boolean? = null @@ -541,16 +540,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } - override fun enableSchedulerDelegateInvalidation(): Boolean { - var cached = enableSchedulerDelegateInvalidationCache - if (cached == null) { - cached = currentProvider.enableSchedulerDelegateInvalidation() - accessedFeatureFlags.add("enableSchedulerDelegateInvalidation") - enableSchedulerDelegateInvalidationCache = 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/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt index cf4e094b051..5dc39a4a116 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.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<<29904c9a4e11c71f7657c49f3f45a32f>> + * @generated SignedSource<> */ /** @@ -25,8 +25,6 @@ public open class ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android : override fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = true - override fun enableSchedulerDelegateInvalidation(): Boolean = true - override fun preventShadowTreeCommitExhaustion(): Boolean = true override fun useSharedAnimatedBackend(): Boolean = true 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 5a5e05d278a..366da3d4575 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<<54381ab2e0b0d3c32451a00ee0a8be96>> + * @generated SignedSource<<100e31bd98a30aba4abef10f168638fc>> */ /** @@ -109,8 +109,6 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableResizeObserverByDefault(): Boolean - @DoNotStrip public fun enableSchedulerDelegateInvalidation(): 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 4bbff49d623..8f8f7cd3a06 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<<7216125910d143e4f0ae9af350687336>> + * @generated SignedSource<> */ /** @@ -297,12 +297,6 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } - bool enableSchedulerDelegateInvalidation() override { - static const auto method = - getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableSchedulerDelegateInvalidation"); - return method(javaProvider_); - } - bool enableSwiftUIBasedFilters() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableSwiftUIBasedFilters"); @@ -774,11 +768,6 @@ bool JReactNativeFeatureFlagsCxxInterop::enableResizeObserverByDefault( return ReactNativeFeatureFlags::enableResizeObserverByDefault(); } -bool JReactNativeFeatureFlagsCxxInterop::enableSchedulerDelegateInvalidation( - facebook::jni::alias_ref /*unused*/) { - return ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation(); -} - bool JReactNativeFeatureFlagsCxxInterop::enableSwiftUIBasedFilters( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableSwiftUIBasedFilters(); @@ -1149,9 +1138,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableResizeObserverByDefault", JReactNativeFeatureFlagsCxxInterop::enableResizeObserverByDefault), - makeNativeMethod( - "enableSchedulerDelegateInvalidation", - JReactNativeFeatureFlagsCxxInterop::enableSchedulerDelegateInvalidation), 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 f672bb63183..71b3da86513 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<<357799e6db7d4644f73a79845104b3d4>> + * @generated SignedSource<<145b12c4a208db86c7bfdfed56cf433f>> */ /** @@ -159,9 +159,6 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableResizeObserverByDefault( facebook::jni::alias_ref); - static bool enableSchedulerDelegateInvalidation( - 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 79c9c9ad976..338b21c5a5f 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<<1e69bcd6066ac1a47c1b4a20eb4eedd4>> + * @generated SignedSource<<9c1052fdfafd3f0ef6bcdaa740cf25ec>> */ /** @@ -198,10 +198,6 @@ bool ReactNativeFeatureFlags::enableResizeObserverByDefault() { return getAccessor().enableResizeObserverByDefault(); } -bool ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation() { - return getAccessor().enableSchedulerDelegateInvalidation(); -} - 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 45bf2708f6e..9fa600171dd 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<<7c7d9b2eb64ecf6b5bd61ff0cc2bb70e>> + * @generated SignedSource<<2d59cf5ea42847d6174fc433ba5a6fe4>> */ /** @@ -254,11 +254,6 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableResizeObserverByDefault(); - /** - * Gates a defensive guard around Scheduler::uiManagerDidDispatchCommand and uiManagerDidFinishTransaction that prevents queued rendering-update lambdas from dereferencing the SchedulerDelegate after it has been destroyed (use-after-free). - */ - RN_EXPORT static bool enableSchedulerDelegateInvalidation(); - /** * 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 21fcd0992b5..f0ba8df3dd6 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<> + * @generated SignedSource<<58600d43eecb5c6593a0edbac4f13ac6>> */ /** @@ -803,24 +803,6 @@ bool ReactNativeFeatureFlagsAccessor::enableResizeObserverByDefault() { return flagValue.value(); } -bool ReactNativeFeatureFlagsAccessor::enableSchedulerDelegateInvalidation() { - auto flagValue = enableSchedulerDelegateInvalidation_.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(43, "enableSchedulerDelegateInvalidation"); - - flagValue = currentProvider_->enableSchedulerDelegateInvalidation(); - enableSchedulerDelegateInvalidation_ = flagValue; - } - - return flagValue.value(); -} - bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { auto flagValue = enableSwiftUIBasedFilters_.load(); @@ -830,7 +812,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(44, "enableSwiftUIBasedFilters"); + markFlagAsAccessed(43, "enableSwiftUIBasedFilters"); flagValue = currentProvider_->enableSwiftUIBasedFilters(); enableSwiftUIBasedFilters_ = flagValue; @@ -848,7 +830,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(45, "enableViewCulling"); + markFlagAsAccessed(44, "enableViewCulling"); flagValue = currentProvider_->enableViewCulling(); enableViewCulling_ = flagValue; @@ -866,7 +848,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(46, "enableViewRecycling"); + markFlagAsAccessed(45, "enableViewRecycling"); flagValue = currentProvider_->enableViewRecycling(); enableViewRecycling_ = flagValue; @@ -884,7 +866,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(47, "enableViewRecyclingForImage"); + markFlagAsAccessed(46, "enableViewRecyclingForImage"); flagValue = currentProvider_->enableViewRecyclingForImage(); enableViewRecyclingForImage_ = flagValue; @@ -902,7 +884,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(48, "enableViewRecyclingForScrollView"); + markFlagAsAccessed(47, "enableViewRecyclingForScrollView"); flagValue = currentProvider_->enableViewRecyclingForScrollView(); enableViewRecyclingForScrollView_ = flagValue; @@ -920,7 +902,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(49, "enableViewRecyclingForText"); + markFlagAsAccessed(48, "enableViewRecyclingForText"); flagValue = currentProvider_->enableViewRecyclingForText(); enableViewRecyclingForText_ = flagValue; @@ -938,7 +920,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(50, "enableViewRecyclingForView"); + markFlagAsAccessed(49, "enableViewRecyclingForView"); flagValue = currentProvider_->enableViewRecyclingForView(); enableViewRecyclingForView_ = flagValue; @@ -956,7 +938,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(51, "enableVirtualViewContainerStateExperimental"); + markFlagAsAccessed(50, "enableVirtualViewContainerStateExperimental"); flagValue = currentProvider_->enableVirtualViewContainerStateExperimental(); enableVirtualViewContainerStateExperimental_ = flagValue; @@ -974,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::fixDifferentiatorParentTagForUnflattenCase // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "fixDifferentiatorParentTagForUnflattenCase"); + markFlagAsAccessed(51, "fixDifferentiatorParentTagForUnflattenCase"); flagValue = currentProvider_->fixDifferentiatorParentTagForUnflattenCase(); fixDifferentiatorParentTagForUnflattenCase_ = flagValue; @@ -992,7 +974,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(53, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(52, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -1010,7 +992,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(54, "fixYogaFlexBasisFitContentInMainAxis"); + markFlagAsAccessed(53, "fixYogaFlexBasisFitContentInMainAxis"); flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis(); fixYogaFlexBasisFitContentInMainAxis_ = flagValue; @@ -1028,7 +1010,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(55, "fuseboxAssertSingleHostState"); + markFlagAsAccessed(54, "fuseboxAssertSingleHostState"); flagValue = currentProvider_->fuseboxAssertSingleHostState(); fuseboxAssertSingleHostState_ = flagValue; @@ -1046,7 +1028,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(56, "fuseboxEnabledRelease"); + markFlagAsAccessed(55, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -1064,7 +1046,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(57, "fuseboxFrameRecordingEnabled"); + markFlagAsAccessed(56, "fuseboxFrameRecordingEnabled"); flagValue = currentProvider_->fuseboxFrameRecordingEnabled(); fuseboxFrameRecordingEnabled_ = flagValue; @@ -1082,7 +1064,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(58, "fuseboxScreenshotCaptureEnabled"); + markFlagAsAccessed(57, "fuseboxScreenshotCaptureEnabled"); flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled(); fuseboxScreenshotCaptureEnabled_ = flagValue; @@ -1100,7 +1082,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(59, "fuseboxWebSocketEventsEnabled"); + markFlagAsAccessed(58, "fuseboxWebSocketEventsEnabled"); flagValue = currentProvider_->fuseboxWebSocketEventsEnabled(); fuseboxWebSocketEventsEnabled_ = flagValue; @@ -1118,7 +1100,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(60, "optimizedAnimatedPropUpdates"); + markFlagAsAccessed(59, "optimizedAnimatedPropUpdates"); flagValue = currentProvider_->optimizedAnimatedPropUpdates(); optimizedAnimatedPropUpdates_ = flagValue; @@ -1136,7 +1118,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(61, "overrideBySynchronousMountPropsAtMountingAndroid"); + markFlagAsAccessed(60, "overrideBySynchronousMountPropsAtMountingAndroid"); flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid(); overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue; @@ -1154,7 +1136,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(62, "perfIssuesEnabled"); + markFlagAsAccessed(61, "perfIssuesEnabled"); flagValue = currentProvider_->perfIssuesEnabled(); perfIssuesEnabled_ = flagValue; @@ -1172,7 +1154,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(63, "perfMonitorV2Enabled"); + markFlagAsAccessed(62, "perfMonitorV2Enabled"); flagValue = currentProvider_->perfMonitorV2Enabled(); perfMonitorV2Enabled_ = flagValue; @@ -1190,7 +1172,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(64, "preparedTextCacheSize"); + markFlagAsAccessed(63, "preparedTextCacheSize"); flagValue = currentProvider_->preparedTextCacheSize(); preparedTextCacheSize_ = flagValue; @@ -1208,7 +1190,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(65, "preventShadowTreeCommitExhaustion"); + markFlagAsAccessed(64, "preventShadowTreeCommitExhaustion"); flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); preventShadowTreeCommitExhaustion_ = flagValue; @@ -1226,7 +1208,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(66, "redBoxV2Android"); + markFlagAsAccessed(65, "redBoxV2Android"); flagValue = currentProvider_->redBoxV2Android(); redBoxV2Android_ = flagValue; @@ -1244,7 +1226,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(67, "redBoxV2IOS"); + markFlagAsAccessed(66, "redBoxV2IOS"); flagValue = currentProvider_->redBoxV2IOS(); redBoxV2IOS_ = flagValue; @@ -1262,7 +1244,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(68, "shouldPressibilityUseW3CPointerEventsForHover"); + markFlagAsAccessed(67, "shouldPressibilityUseW3CPointerEventsForHover"); flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; @@ -1280,7 +1262,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(69, "shouldTriggerResponderTransferOnScrollAndroid"); + markFlagAsAccessed(68, "shouldTriggerResponderTransferOnScrollAndroid"); flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid(); shouldTriggerResponderTransferOnScrollAndroid_ = flagValue; @@ -1298,7 +1280,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(70, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(69, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -1316,7 +1298,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(71, "syncAndroidClipBoundsWithOverflow"); + markFlagAsAccessed(70, "syncAndroidClipBoundsWithOverflow"); flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow(); syncAndroidClipBoundsWithOverflow_ = flagValue; @@ -1334,7 +1316,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(72, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(71, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -1352,7 +1334,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(73, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(72, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -1370,7 +1352,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(74, "updateRuntimeShadowNodeReferencesOnCommitThread"); + markFlagAsAccessed(73, "updateRuntimeShadowNodeReferencesOnCommitThread"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread(); updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue; @@ -1388,7 +1370,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(75, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(74, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -1406,7 +1388,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(76, "useFabricInterop"); + markFlagAsAccessed(75, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1424,7 +1406,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(77, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(76, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1442,7 +1424,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(78, "useNestedScrollViewAndroid"); + markFlagAsAccessed(77, "useNestedScrollViewAndroid"); flagValue = currentProvider_->useNestedScrollViewAndroid(); useNestedScrollViewAndroid_ = flagValue; @@ -1460,7 +1442,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(79, "useSharedAnimatedBackend"); + markFlagAsAccessed(78, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1478,7 +1460,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(80, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(79, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1496,7 +1478,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(81, "useTurboModuleInterop"); + markFlagAsAccessed(80, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1514,7 +1496,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(82, "viewCullingOutsetRatio"); + markFlagAsAccessed(81, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1532,7 +1514,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(83, "viewTransitionEnabled"); + markFlagAsAccessed(82, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1550,7 +1532,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(84, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(83, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1568,7 +1550,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(85, "virtualViewPrerenderRatio"); + markFlagAsAccessed(84, "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 5e95b538143..4f5d310ebe4 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<<6bfe194529e322fc98e43f6fe87cebeb>> + * @generated SignedSource<<55f19e7a0d7fbbda3aa131a74909ec07>> */ /** @@ -75,7 +75,6 @@ class ReactNativeFeatureFlagsAccessor { bool enablePreparedTextLayout(); bool enablePropsUpdateReconciliationAndroid(); bool enableResizeObserverByDefault(); - bool enableSchedulerDelegateInvalidation(); bool enableSwiftUIBasedFilters(); bool enableViewCulling(); bool enableViewRecycling(); @@ -129,7 +128,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 86> accessedFeatureFlags_; + std::array, 85> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; @@ -174,7 +173,6 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> enablePreparedTextLayout_; std::atomic> enablePropsUpdateReconciliationAndroid_; std::atomic> enableResizeObserverByDefault_; - std::atomic> enableSchedulerDelegateInvalidation_; 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 abb19849bc1..5e144a27181 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<<8e00ed57e2faa8e13ae2eb58afd64962>> */ /** @@ -199,10 +199,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } - bool enableSchedulerDelegateInvalidation() 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 017b02b31ad..a969aad4ad0 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<<30b0399ab09d2d273c465bfa950a5a15>> + * @generated SignedSource<<9c0b6df9433a5696f5eacf47713b9040>> */ /** @@ -432,15 +432,6 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::enableResizeObserverByDefault(); } - bool enableSchedulerDelegateInvalidation() override { - auto value = values_["enableSchedulerDelegateInvalidation"]; - if (!value.isNull()) { - return value.getBool(); - } - - return ReactNativeFeatureFlagsDefaults::enableSchedulerDelegateInvalidation(); - } - bool enableSwiftUIBasedFilters() override { auto value = values_["enableSwiftUIBasedFilters"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h index 428424b850a..dad6dca0cca 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.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<<764568389a1ae8675638104ab3d96d4d>> + * @generated SignedSource<> */ /** @@ -31,10 +31,6 @@ class ReactNativeFeatureFlagsOverridesOSSExperimental : public ReactNativeFeatur return true; } - bool enableSchedulerDelegateInvalidation() override { - return true; - } - bool preventShadowTreeCommitExhaustion() override { return true; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index b2c25df4be3..d7e20196f59 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<<7ebf2d5220215a3d02ce496257c7d3e0>> + * @generated SignedSource<<51d2bd8d3e88e7848039f845c1709a39>> */ /** @@ -68,7 +68,6 @@ class ReactNativeFeatureFlagsProvider { virtual bool enablePreparedTextLayout() = 0; virtual bool enablePropsUpdateReconciliationAndroid() = 0; virtual bool enableResizeObserverByDefault() = 0; - virtual bool enableSchedulerDelegateInvalidation() = 0; virtual bool enableSwiftUIBasedFilters() = 0; virtual bool enableViewCulling() = 0; virtual bool enableViewRecycling() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 18a822e60a9..bdd78c775a5 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<<8bef73ce7833191807c05d34586612dd>> + * @generated SignedSource<<54cf6211f3dbfc379c6058cbc9d9af07>> */ /** @@ -259,11 +259,6 @@ bool NativeReactNativeFeatureFlags::enableResizeObserverByDefault( return ReactNativeFeatureFlags::enableResizeObserverByDefault(); } -bool NativeReactNativeFeatureFlags::enableSchedulerDelegateInvalidation( - jsi::Runtime& /*runtime*/) { - return ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation(); -} - 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 233ae210247..c3be1b5fba5 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<<9e8d3d0a144ac859479d5ef5b1b12f2f>> + * @generated SignedSource<<2c30d3942ab1183a99091db3566c020d>> */ /** @@ -124,8 +124,6 @@ class NativeReactNativeFeatureFlags bool enableResizeObserverByDefault(jsi::Runtime& runtime); - bool enableSchedulerDelegateInvalidation(jsi::Runtime& runtime); - bool enableSwiftUIBasedFilters(jsi::Runtime& runtime); bool enableViewCulling(jsi::Runtime& runtime); diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index b5fa421a35a..e74e8025c26 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -31,8 +31,7 @@ Scheduler::Scheduler( const SchedulerToolbox& schedulerToolbox, UIManagerAnimationDelegate* animationDelegate, SchedulerDelegate* delegate) - : delegateInvalidated_(std::make_shared>(false)), - runtimeExecutor_(schedulerToolbox.runtimeExecutor), + : runtimeExecutor_(schedulerToolbox.runtimeExecutor), contextContainer_(schedulerToolbox.contextContainer) { // Creating a container for future `EventDispatcher` instance. eventDispatcher_ = std::make_shared>(); @@ -182,15 +181,6 @@ Scheduler::~Scheduler() { LOG(WARNING) << "Scheduler::~Scheduler() was called (address: " << this << ")."; - // Invalidate any lambdas already queued via scheduleRenderingUpdate that - // captured a raw delegate_ pointer; without this they'd dereference a - // dangling SchedulerDelegate after Scheduler teardown. (No replacement - // token is allocated here — Scheduler is going away.) - // Gated to allow controlled rollout / rollback. - if (ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation()) { - *delegateInvalidated_ = true; - } - auto weakRuntimeScheduler = contextContainer_->find>( RuntimeSchedulerKey); @@ -280,21 +270,6 @@ Scheduler::findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN( #pragma mark - Delegate void Scheduler::setDelegate(SchedulerDelegate* delegate) { - // Gated to allow controlled rollout / rollback. - if (ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation() && - delegate_ != delegate) { - // Mark the *current* token invalid: any rendering-update lambda already - // queued holds a shared_ptr to this atomic and will observe `true` on - // its next read, so it no-ops instead of calling into the previous - // delegate (which the caller is about to drop). - *delegateInvalidated_ = true; - // Then install a *fresh* token (a new atomic) so lambdas captured - // against the new delegate use their own non-invalidated flag. - // Reusing the previous atomic and flipping it back to `false` would - // re-arm the in-flight lambdas — exactly the use-after-free we're - // trying to prevent — because they share the same shared_ptr. - delegateInvalidated_ = std::make_shared>(false); - } delegate_ = delegate; } @@ -326,21 +301,10 @@ void Scheduler::uiManagerDidFinishTransaction( if (!mountSynchronously) { auto surfaceId = mountingCoordinator->getSurfaceId(); - // Capture the gating flag at queue time: the lambda's decision to - // honor the invalidation guard is fixed when we enqueue, not when it - // later runs. Avoids per-invocation feature-flag reads and keeps the - // contract for an in-flight lambda stable across flag flips. - auto guardEnabled = - ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation(); runtimeScheduler_->scheduleRenderingUpdate( surfaceId, [delegate = delegate_, - invalidated = delegateInvalidated_, - guardEnabled, mountingCoordinator = std::move(mountingCoordinator)]() { - if (guardEnabled && *invalidated) { - return; - } delegate->schedulerShouldRenderTransactions(mountingCoordinator); }); } else { @@ -363,20 +327,12 @@ void Scheduler::uiManagerDidDispatchCommand( "Scheduler::uiManagerDispatchCommand", "commandName", commandName); if (delegate_ != nullptr) { auto shadowView = ShadowView(*shadowNode); - // See comment in uiManagerDidFinishTransaction above for gating shape. - auto guardEnabled = - ReactNativeFeatureFlags::enableSchedulerDelegateInvalidation(); runtimeScheduler_->scheduleRenderingUpdate( shadowNode->getSurfaceId(), [delegate = delegate_, - invalidated = delegateInvalidated_, - guardEnabled, shadowView = std::move(shadowView), commandName, args]() { - if (guardEnabled && *invalidated) { - return; - } delegate->schedulerDidDispatchCommand(shadowView, commandName, args); }); } diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h index bdac7c97422..1f5a59d1e1e 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -126,11 +126,6 @@ class Scheduler final : public UIManagerDelegate { friend class SurfaceHandler; SchedulerDelegate *delegate_; - // Invalidation token captured by-value into lambdas deferred via - // runtimeScheduler_->scheduleRenderingUpdate. Set to true on delegate - // change or Scheduler destruction so a lambda that outlives its captured - // raw delegate pointer can no-op instead of dereferencing dangling memory. - std::shared_ptr> delegateInvalidated_; SharedComponentDescriptorRegistry componentDescriptorRegistry_; RuntimeExecutor runtimeExecutor_; std::shared_ptr uiManager_; diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/tests/SchedulerDelegateInvalidationTest.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/tests/SchedulerDelegateInvalidationTest.cpp index 47fb0efd364..16dc0ab2665 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/tests/SchedulerDelegateInvalidationTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/tests/SchedulerDelegateInvalidationTest.cpp @@ -12,8 +12,9 @@ // uiManagerDidDispatchCommand). The lambda captures the delegate by raw // pointer; if the delegate is destroyed (as part of an instance teardown // triggered by an uncaught fatal error) before the lambda runs, the -// dereference is a use-after-free unless the invalidation-token guard in -// Scheduler::setDelegate is enabled at queue time. +// dereference is a use-after-free. What closes the race is +// RuntimeScheduler_Modern::handleTaskError, which clears the pending +// rendering updates before the host error handler drops the delegate. // // The test drives the *real* Scheduler::uiManagerDidFinishTransaction so the // rendering-update lambda is enqueued via the regular code path into a real @@ -196,26 +197,16 @@ class TestExecutorQueue { std::queue> queue_; }; -// Feature flags relevant to this test: -// - enableSchedulerDelegateInvalidation: the token guard under test. -// - enableBridgelessArchitecture: forced ON so the Scheduler picks -// RuntimeScheduler_Modern. Modern queues rendering updates in -// pendingRenderingUpdates_ and drains them at end-of-tick, which is the -// ordering required to expose the race. RuntimeScheduler_Legacy runs -// scheduleRenderingUpdate inline, collapsing the window we want to test. +// enableBridgelessArchitecture is forced ON so the Scheduler picks +// RuntimeScheduler_Modern. Modern queues rendering updates in +// pendingRenderingUpdates_ and drains them at end-of-tick, which is the +// ordering required to expose the race. RuntimeScheduler_Legacy runs +// scheduleRenderingUpdate inline, collapsing the window we want to test. class TestFeatureFlags : public ReactNativeFeatureFlagsDefaults { public: - explicit TestFeatureFlags(bool guardEnabled) : guardEnabled_(guardEnabled) {} - bool enableBridgelessArchitecture() override { return true; } - bool enableSchedulerDelegateInvalidation() override { - return guardEnabled_; - } - - private: - bool guardEnabled_; }; // Builds a ComponentRegistryFactory with just the descriptors needed for the @@ -242,9 +233,8 @@ ComponentRegistryFactory makeComponentRegistryFactory() { // a real Scheduler and drive uiManagerDidFinishTransaction end-to-end. class SchedulerDelegateInvalidationTest : public ::testing::Test { protected: - void setUp(bool guardEnabled) { - ReactNativeFeatureFlags::override( - std::make_unique(guardEnabled)); + void setUp() { + ReactNativeFeatureFlags::override(std::make_unique()); runtime_ = facebook::hermes::makeHermesRuntime( ::hermes::vm::RuntimeConfig::Builder() @@ -433,7 +423,7 @@ class SchedulerDelegateInvalidationTest : public ::testing::Test { TEST_F( SchedulerDelegateInvalidationTest, Sanity_LambdaRunsOnNextTickWhenDelegateAlive) { - setUp(/*guardEnabled=*/true); + setUp(); scheduler_->uiManagerDidFinishTransaction( coordinator_, /*mountSynchronously=*/false); @@ -451,7 +441,7 @@ TEST_F( } // --------------------------------------------------------------------------- -// Test 2 — JS-throw-initiated teardown, guard ENABLED. +// Test 2 — JS-throw-initiated teardown. // // Cascade replicated in C++: // (a) earlier transaction enqueued a rendering-update lambda into @@ -461,13 +451,12 @@ TEST_F( // host-driven instance teardown by dropping the delegate // (d) the next tick drains the previously-queued rendering update // -// With the guard ON, step (c) flipped the invalidation token; the pending -// lambda observes that and returns before touching the freed delegate. Safe. +// RuntimeScheduler_Modern clears pendingRenderingUpdates_ in handleTaskError +// before running onTaskError, so by (d) there is no stale delegate lambda +// left to drain. The post-error task is dropped by the same clearing. // --------------------------------------------------------------------------- -TEST_F( - SchedulerDelegateInvalidationTest, - GuardEnabled_JSThrowInitiatedTeardownIsSafe) { - setUp(/*guardEnabled=*/true); +TEST_F(SchedulerDelegateInvalidationTest, JSThrowInitiatedTeardownIsSafe) { + setUp(); // (a) Pre-throw transaction: lambda lands in pendingRenderingUpdates_. scheduler_->uiManagerDidFinishTransaction( @@ -477,73 +466,43 @@ TEST_F( // (b) Schedule a JS task that throws uncaught. Draining the executor queue // runs the task; the throw flows through to onTaskError → teardown. scheduleJSThrowingTask(); + schedulePostErrorTask(); executorQueue_->flush(); // Sanity: the simulated fatal cascade fired and the delegate is gone. EXPECT_TRUE(jsThrowObserved_); EXPECT_EQ(scheduler_->getDelegate(), nullptr); - - // (d) Drain the pending rendering update. Guard is on → lambda no-ops. - runOneEventLoopTick(); - - SUCCEED(); -} - -// --------------------------------------------------------------------------- -// Test 3 — JS-throw-initiated teardown, guard DISABLED. -// -// Same cascade as Test 2 but with the scheduler invalidation guard OFF. The -// runtime scheduler clears pendingRenderingUpdates_ before onTaskError tears -// down the delegate, so the later tick has no stale delegate lambda to drain -// even without the guard. -// --------------------------------------------------------------------------- -TEST_F( - SchedulerDelegateInvalidationTest, - GuardDisabled_JSThrowInitiatedTeardownIsSafe) { - setUp(/*guardEnabled=*/false); - - scheduler_->uiManagerDidFinishTransaction( - coordinator_, /*mountSynchronously=*/false); - EXPECT_EQ(delegate_->shouldRenderTransactionsCount(), 0); - - scheduleJSThrowingTask(); - schedulePostErrorTask(); - executorQueue_->flush(); - EXPECT_TRUE(jsThrowObserved_); - EXPECT_EQ(scheduler_->getDelegate(), nullptr); EXPECT_FALSE(postErrorTaskRan_); + // (d) Drain the rendering-update queue — already emptied by the clearing. runOneEventLoopTick(); SUCCEED(); } // --------------------------------------------------------------------------- -// Test 4 — The window the guard still closes: a delegate dropped and -// destroyed with no error involved. +// Test 3 — The window that remains open: a delegate dropped and destroyed +// with no error involved. // -// Retargeted from a JS-throw trigger, which can no longer reach this race: // handleTaskError clears pendingRenderingUpdates_ before the host error -// handler runs, so the queue is already empty by the time the delegate goes -// away (Test 3). A plain setDelegate swap never reaches handleTaskError, so -// with the guard OFF the lambda enqueued in (a) still holds a raw pointer to -// freed memory when the queue drains in (c). +// handler runs, so an error-driven teardown is safe (Test 3). A plain +// setDelegate swap never reaches handleTaskError, so the lambda enqueued in +// (a) still holds a raw pointer to freed memory when the queue drains in (c). // --------------------------------------------------------------------------- #if GTEST_HAS_DEATH_TEST TEST_F( SchedulerDelegateInvalidationTest, - GuardDisabled_DelegateDestroyedWithoutError_IsUAF) { + DelegateDestroyedWithoutError_PendingRenderingUpdateIsUAF) { EXPECT_DEATH( { - setUp(/*guardEnabled=*/false); + setUp(); // (a) Enqueue a rendering-update lambda capturing delegate_ raw. scheduler_->uiManagerDidFinishTransaction( coordinator_, /*mountSynchronously=*/false); // (b) Host swaps the delegate out and destroys it. No JS throw, so - // nothing clears the rendering-update queue. With the guard ON, - // setDelegate would flip the invalidation token here. + // nothing clears the rendering-update queue. scheduler_->setDelegate(nullptr); delegate_.reset(); @@ -555,21 +514,20 @@ TEST_F( #endif // --------------------------------------------------------------------------- -// Test 5 — Same race as Test 2, but enqueued via the second lambda site: +// Test 4 — Same race as Test 2, but enqueued via the second lambda site: // Scheduler::uiManagerDidDispatchCommand. This is the path the in-app // reproduction observed (a `scrollTo` command issued from a tap, queued -// just before the cascade fatal). With the guard ON the lambda observes -// the invalidation token and no-ops. +// just before the cascade fatal). // --------------------------------------------------------------------------- TEST_F( SchedulerDelegateInvalidationTest, - GuardEnabled_DispatchCommandLambda_JSThrowInitiatedTeardownIsSafe) { - setUp(/*guardEnabled=*/true); + DispatchCommandLambda_JSThrowInitiatedTeardownIsSafe) { + setUp(); ASSERT_NE(rootShadowNode_, nullptr); // (a) Pre-throw command: enqueues a rendering-update lambda inside // Scheduler::uiManagerDidDispatchCommand that captures the delegate by - // raw pointer and the invalidation token by shared_ptr. + // raw pointer. scheduler_->uiManagerDidDispatchCommand( rootShadowNode_, "scrollTo", folly::dynamic::array()); EXPECT_EQ(delegate_->didDispatchCommandCount(), 0); @@ -580,14 +538,14 @@ TEST_F( EXPECT_TRUE(jsThrowObserved_); EXPECT_EQ(scheduler_->getDelegate(), nullptr); - // (c) Drain the pending rendering update. Guard ON → lambda no-ops. + // (c) Drain the rendering-update queue — already emptied by the clearing. runOneEventLoopTick(); SUCCEED(); } // --------------------------------------------------------------------------- -// Test 6 — Architectural assertion: surface-shutdown alone does NOT drain +// Test 5 — Architectural assertion: surface-shutdown alone does NOT drain // pendingRenderingUpdates_ in RuntimeScheduler_Modern. // // This is the explicit refutation of the implicit reading "if the host just @@ -595,13 +553,13 @@ TEST_F( // race wouldn't be reachable." It would not — surface-shutdown clears the // per-surface UIManager pointer but doesn't touch the runtime scheduler's // pending-rendering-updates queue. The lambda still runs and still calls -// the delegate. Only the invalidation-token guard (or, longer-term, a -// runtime-scheduler-level shutdown signal) closes this race. +// the delegate. Only an error-driven queue clear, or a longer-term +// runtime-scheduler-level shutdown signal, closes this race. // --------------------------------------------------------------------------- TEST_F( SchedulerDelegateInvalidationTest, UnregisterSurface_DoesNotDrainPendingRenderingUpdates) { - setUp(/*guardEnabled=*/true); + setUp(); // (a) Enqueue a rendering-update lambda for the registered surface. scheduler_->uiManagerDidFinishTransaction( diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index a49b4b6bb22..ded56d14688 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -505,17 +505,6 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - enableSchedulerDelegateInvalidation: { - defaultValue: false, - metadata: { - dateAdded: '2026-05-04', - description: - 'Gates a defensive guard around Scheduler::uiManagerDidDispatchCommand and uiManagerDidFinishTransaction that prevents queued rendering-update lambdas from dereferencing the SchedulerDelegate after it has been destroyed (use-after-free).', - expectedReleaseValue: true, - purpose: 'experimentation', - }, - ossReleaseStage: 'experimental', - }, 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 f56a70e2ccc..c62bad74d89 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<<9bdc0e5397839b38c408db16dd2fffdc>> + * @generated SignedSource<<0774261e9f27a2df5005e11317556f83>> * @flow strict * @noformat */ @@ -92,7 +92,6 @@ export type ReactNativeFeatureFlags = Readonly<{ enablePreparedTextLayout: Getter, enablePropsUpdateReconciliationAndroid: Getter, enableResizeObserverByDefault: Getter, - enableSchedulerDelegateInvalidation: Getter, enableSwiftUIBasedFilters: Getter, enableViewCulling: Getter, enableViewRecycling: Getter, @@ -383,10 +382,6 @@ export const enablePropsUpdateReconciliationAndroid: Getter = createNat * Enables the ResizeObserver Web API in React Native. */ export const enableResizeObserverByDefault: Getter = createNativeFlagGetter('enableResizeObserverByDefault', false); -/** - * Gates a defensive guard around Scheduler::uiManagerDidDispatchCommand and uiManagerDidFinishTransaction that prevents queued rendering-update lambdas from dereferencing the SchedulerDelegate after it has been destroyed (use-after-free). - */ -export const enableSchedulerDelegateInvalidation: Getter = createNativeFlagGetter('enableSchedulerDelegateInvalidation', 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 35bcb641997..7d646a6a59d 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<> * @flow strict * @noformat */ @@ -68,7 +68,6 @@ export interface Spec extends TurboModule { readonly enablePreparedTextLayout?: () => boolean; readonly enablePropsUpdateReconciliationAndroid?: () => boolean; readonly enableResizeObserverByDefault?: () => boolean; - readonly enableSchedulerDelegateInvalidation?: () => boolean; readonly enableSwiftUIBasedFilters?: () => boolean; readonly enableViewCulling?: () => boolean; readonly enableViewRecycling?: () => boolean;