Remove fixFindShadowNodeByTagRaceCondition feature flag (#56850)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56850

The `fixFindShadowNodeByTagRaceCondition` feature flag has been fully rolled out on both iOS and Android. This change removes the flag and makes the fixed behavior the permanent default.

The fix (https://github.com/facebook/react-native/pull/55751) replaced a use-after-free race condition in `findShadowNodeByTag_DEPRECATED` where a raw pointer was captured via `tryCommit()` and could dangle after a concurrent surface stop. The fixed code path uses `getCurrentRevision()` which returns a `shared_ptr` that keeps the root alive for the entire traversal.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D105322626

fbshipit-source-id: 018a6a3646bbca9e8f7854848a8a3ea5f2dbf1d0
This commit is contained in:
Peter Abbondanzo authored and meta-codesync[bot] committed 2026-05-15 13:03:04 -07:00
1 parent e705e8d971
commit 8636cadb8e
22 files changed
+59 -249

No files matched your search

@@ -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<<4342ccb696b4123b9d463a31c024b9bc>>
* @generated SignedSource<<794be726d31bf395558bb987d94c3205>>
*/
/**
@@ -354,12 +354,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun fixDifferentiatorParentTagForUnflattenCase(): Boolean = accessor.fixDifferentiatorParentTagForUnflattenCase()
/**
* Fix a use-after-free race condition in findShadowNodeByTag_DEPRECATED by using getCurrentRevision() instead of tryCommit() with a raw pointer.
*/
@JvmStatic
public fun fixFindShadowNodeByTagRaceCondition(): Boolean = accessor.fixFindShadowNodeByTagRaceCondition()
/**
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
*/
@@ -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<<ec375fbc64b2b2b8995c1640a0369923>>
* @generated SignedSource<<e91fab99f355307aac38de7a5c84e8dd>>
*/
/**
@@ -74,7 +74,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var fixDifferentiatorParentTagForUnflattenCaseCache: Boolean? = null
private var fixFindShadowNodeByTagRaceConditionCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fixYogaFlexBasisFitContentInMainAxisCache: Boolean? = null
private var fuseboxAssertSingleHostStateCache: Boolean? = null
@@ -599,15 +598,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun fixFindShadowNodeByTagRaceCondition(): Boolean {
var cached = fixFindShadowNodeByTagRaceConditionCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.fixFindShadowNodeByTagRaceCondition()
fixFindShadowNodeByTagRaceConditionCache = cached
}
return cached
}
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
if (cached == null) {
@@ -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<<81989dbed82df7bd963d8023c595ff44>>
* @generated SignedSource<<9d1f725d5a1348a2b31ad4ea2242529c>>
*/
/**
@@ -136,8 +136,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun fixDifferentiatorParentTagForUnflattenCase(): Boolean
@DoNotStrip @JvmStatic public external fun fixFindShadowNodeByTagRaceCondition(): Boolean
@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip @JvmStatic public external fun fixYogaFlexBasisFitContentInMainAxis(): Boolean
@@ -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<<93e83fb3dc9577acd9678803321e0fe1>>
* @generated SignedSource<<f63cf074bb6687c479e2f4059662ff76>>
*/
/**
@@ -131,8 +131,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun fixDifferentiatorParentTagForUnflattenCase(): Boolean = false
override fun fixFindShadowNodeByTagRaceCondition(): Boolean = false
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
override fun fixYogaFlexBasisFitContentInMainAxis(): Boolean = false
@@ -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<<9d07e8adeee69583b788069649306d8e>>
* @generated SignedSource<<27e88ec53841585796515db0406909dd>>
*/
/**
@@ -78,7 +78,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var fixDifferentiatorParentTagForUnflattenCaseCache: Boolean? = null
private var fixFindShadowNodeByTagRaceConditionCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fixYogaFlexBasisFitContentInMainAxisCache: Boolean? = null
private var fuseboxAssertSingleHostStateCache: Boolean? = null
@@ -657,16 +656,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun fixFindShadowNodeByTagRaceCondition(): Boolean {
var cached = fixFindShadowNodeByTagRaceConditionCache
if (cached == null) {
cached = currentProvider.fixFindShadowNodeByTagRaceCondition()
accessedFeatureFlags.add("fixFindShadowNodeByTagRaceCondition")
fixFindShadowNodeByTagRaceConditionCache = cached
}
return cached
}
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
if (cached == null) {
@@ -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<<bcc599e04e3672d4bff293e267b3efa2>>
* @generated SignedSource<<5670b927124074a4c59b692de8599cd5>>
*/
/**
@@ -131,8 +131,6 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun fixDifferentiatorParentTagForUnflattenCase(): Boolean
@DoNotStrip public fun fixFindShadowNodeByTagRaceCondition(): Boolean
@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip public fun fixYogaFlexBasisFitContentInMainAxis(): Boolean
@@ -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<<32c8c18771d6690f50d60dbc8e3d07e2>>
* @generated SignedSource<<52bf46b50e91dacdac8d43c4c00ea6f3>>
*/
/**
@@ -363,12 +363,6 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool fixFindShadowNodeByTagRaceCondition() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixFindShadowNodeByTagRaceCondition");
return method(javaProvider_);
}
bool fixMappingOfEventPrioritiesBetweenFabricAndReact() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixMappingOfEventPrioritiesBetweenFabricAndReact");
@@ -865,11 +859,6 @@ bool JReactNativeFeatureFlagsCxxInterop::fixDifferentiatorParentTagForUnflattenC
return ReactNativeFeatureFlags::fixDifferentiatorParentTagForUnflattenCase();
}
bool JReactNativeFeatureFlagsCxxInterop::fixFindShadowNodeByTagRaceCondition(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition();
}
bool JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
@@ -1248,9 +1237,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"fixDifferentiatorParentTagForUnflattenCase",
JReactNativeFeatureFlagsCxxInterop::fixDifferentiatorParentTagForUnflattenCase),
makeNativeMethod(
"fixFindShadowNodeByTagRaceCondition",
JReactNativeFeatureFlagsCxxInterop::fixFindShadowNodeByTagRaceCondition),
makeNativeMethod(
"fixMappingOfEventPrioritiesBetweenFabricAndReact",
JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact),
@@ -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<<aacbc520b40625dbdba328590cc78112>>
* @generated SignedSource<<f43b6cb2603f2c6dd2da415c4edc0a64>>
*/
/**
@@ -192,9 +192,6 @@ class JReactNativeFeatureFlagsCxxInterop
static bool fixDifferentiatorParentTagForUnflattenCase(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool fixFindShadowNodeByTagRaceCondition(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool fixMappingOfEventPrioritiesBetweenFabricAndReact(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -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<<483ac339c0d636c85f4639c60982c504>>
* @generated SignedSource<<19a0fa951fda8419542fe2fc376c40f9>>
*/
/**
@@ -242,10 +242,6 @@ bool ReactNativeFeatureFlags::fixDifferentiatorParentTagForUnflattenCase() {
return getAccessor().fixDifferentiatorParentTagForUnflattenCase();
}
bool ReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition() {
return getAccessor().fixFindShadowNodeByTagRaceCondition();
}
bool ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact() {
return getAccessor().fixMappingOfEventPrioritiesBetweenFabricAndReact();
}
@@ -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<<771a335070649f38cb559a95d80947aa>>
* @generated SignedSource<<f62617faffa739ee7822e44f3e5ff130>>
*/
/**
@@ -309,11 +309,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool fixDifferentiatorParentTagForUnflattenCase();
/**
* Fix a use-after-free race condition in findShadowNodeByTag_DEPRECATED by using getCurrentRevision() instead of tryCommit() with a raw pointer.
*/
RN_EXPORT static bool fixFindShadowNodeByTagRaceCondition();
/**
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
*/
@@ -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<<5054704ec35884395b7b3668169a8871>>
* @generated SignedSource<<97f98b25281a3b213e3d90b7b687da04>>
*/
/**
@@ -1001,24 +1001,6 @@ bool ReactNativeFeatureFlagsAccessor::fixDifferentiatorParentTagForUnflattenCase
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::fixFindShadowNodeByTagRaceCondition() {
auto flagValue = fixFindShadowNodeByTagRaceCondition_.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(54, "fixFindShadowNodeByTagRaceCondition");
flagValue = currentProvider_->fixFindShadowNodeByTagRaceCondition();
fixFindShadowNodeByTagRaceCondition_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAndReact() {
auto flagValue = fixMappingOfEventPrioritiesBetweenFabricAndReact_.load();
@@ -1028,7 +1010,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(55, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
markFlagAsAccessed(54, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact();
fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue;
@@ -1046,7 +1028,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(56, "fixYogaFlexBasisFitContentInMainAxis");
markFlagAsAccessed(55, "fixYogaFlexBasisFitContentInMainAxis");
flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis();
fixYogaFlexBasisFitContentInMainAxis_ = flagValue;
@@ -1064,7 +1046,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(57, "fuseboxAssertSingleHostState");
markFlagAsAccessed(56, "fuseboxAssertSingleHostState");
flagValue = currentProvider_->fuseboxAssertSingleHostState();
fuseboxAssertSingleHostState_ = flagValue;
@@ -1082,7 +1064,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(58, "fuseboxEnabledRelease");
markFlagAsAccessed(57, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -1100,7 +1082,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(59, "fuseboxFrameRecordingEnabled");
markFlagAsAccessed(58, "fuseboxFrameRecordingEnabled");
flagValue = currentProvider_->fuseboxFrameRecordingEnabled();
fuseboxFrameRecordingEnabled_ = flagValue;
@@ -1118,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxNetworkInspectionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(60, "fuseboxNetworkInspectionEnabled");
markFlagAsAccessed(59, "fuseboxNetworkInspectionEnabled");
flagValue = currentProvider_->fuseboxNetworkInspectionEnabled();
fuseboxNetworkInspectionEnabled_ = flagValue;
@@ -1136,7 +1118,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(61, "fuseboxScreenshotCaptureEnabled");
markFlagAsAccessed(60, "fuseboxScreenshotCaptureEnabled");
flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled();
fuseboxScreenshotCaptureEnabled_ = flagValue;
@@ -1154,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::hideOffscreenVirtualViewsOnIOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(62, "hideOffscreenVirtualViewsOnIOS");
markFlagAsAccessed(61, "hideOffscreenVirtualViewsOnIOS");
flagValue = currentProvider_->hideOffscreenVirtualViewsOnIOS();
hideOffscreenVirtualViewsOnIOS_ = flagValue;
@@ -1172,7 +1154,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(63, "optimizedAnimatedPropUpdates");
markFlagAsAccessed(62, "optimizedAnimatedPropUpdates");
flagValue = currentProvider_->optimizedAnimatedPropUpdates();
optimizedAnimatedPropUpdates_ = flagValue;
@@ -1190,7 +1172,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(64, "overrideBySynchronousMountPropsAtMountingAndroid");
markFlagAsAccessed(63, "overrideBySynchronousMountPropsAtMountingAndroid");
flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid();
overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue;
@@ -1208,7 +1190,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(65, "perfIssuesEnabled");
markFlagAsAccessed(64, "perfIssuesEnabled");
flagValue = currentProvider_->perfIssuesEnabled();
perfIssuesEnabled_ = flagValue;
@@ -1226,7 +1208,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(66, "perfMonitorV2Enabled");
markFlagAsAccessed(65, "perfMonitorV2Enabled");
flagValue = currentProvider_->perfMonitorV2Enabled();
perfMonitorV2Enabled_ = flagValue;
@@ -1244,7 +1226,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(67, "preparedTextCacheSize");
markFlagAsAccessed(66, "preparedTextCacheSize");
flagValue = currentProvider_->preparedTextCacheSize();
preparedTextCacheSize_ = flagValue;
@@ -1262,7 +1244,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(68, "preventShadowTreeCommitExhaustion");
markFlagAsAccessed(67, "preventShadowTreeCommitExhaustion");
flagValue = currentProvider_->preventShadowTreeCommitExhaustion();
preventShadowTreeCommitExhaustion_ = flagValue;
@@ -1280,7 +1262,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(69, "redBoxV2Android");
markFlagAsAccessed(68, "redBoxV2Android");
flagValue = currentProvider_->redBoxV2Android();
redBoxV2Android_ = flagValue;
@@ -1298,7 +1280,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(70, "redBoxV2IOS");
markFlagAsAccessed(69, "redBoxV2IOS");
flagValue = currentProvider_->redBoxV2IOS();
redBoxV2IOS_ = flagValue;
@@ -1316,7 +1298,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(71, "shouldPressibilityUseW3CPointerEventsForHover");
markFlagAsAccessed(70, "shouldPressibilityUseW3CPointerEventsForHover");
flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover();
shouldPressibilityUseW3CPointerEventsForHover_ = flagValue;
@@ -1334,7 +1316,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(72, "shouldTriggerResponderTransferOnScrollAndroid");
markFlagAsAccessed(71, "shouldTriggerResponderTransferOnScrollAndroid");
flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid();
shouldTriggerResponderTransferOnScrollAndroid_ = flagValue;
@@ -1352,7 +1334,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(73, "skipActivityIdentityAssertionOnHostPause");
markFlagAsAccessed(72, "skipActivityIdentityAssertionOnHostPause");
flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause();
skipActivityIdentityAssertionOnHostPause_ = flagValue;
@@ -1370,7 +1352,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(74, "syncAndroidClipBoundsWithOverflow");
markFlagAsAccessed(73, "syncAndroidClipBoundsWithOverflow");
flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow();
syncAndroidClipBoundsWithOverflow_ = flagValue;
@@ -1388,7 +1370,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(75, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(74, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -1406,7 +1388,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(76, "updateRuntimeShadowNodeReferencesOnCommit");
markFlagAsAccessed(75, "updateRuntimeShadowNodeReferencesOnCommit");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit();
updateRuntimeShadowNodeReferencesOnCommit_ = flagValue;
@@ -1424,7 +1406,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(77, "updateRuntimeShadowNodeReferencesOnCommitThread");
markFlagAsAccessed(76, "updateRuntimeShadowNodeReferencesOnCommitThread");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread();
updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue;
@@ -1442,7 +1424,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(78, "useAlwaysAvailableJSErrorHandling");
markFlagAsAccessed(77, "useAlwaysAvailableJSErrorHandling");
flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling();
useAlwaysAvailableJSErrorHandling_ = flagValue;
@@ -1460,7 +1442,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(79, "useFabricInterop");
markFlagAsAccessed(78, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -1478,7 +1460,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(80, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(79, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -1496,7 +1478,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(81, "useNestedScrollViewAndroid");
markFlagAsAccessed(80, "useNestedScrollViewAndroid");
flagValue = currentProvider_->useNestedScrollViewAndroid();
useNestedScrollViewAndroid_ = flagValue;
@@ -1514,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedViewRegistryOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(82, "useOptimizedViewRegistryOnAndroid");
markFlagAsAccessed(81, "useOptimizedViewRegistryOnAndroid");
flagValue = currentProvider_->useOptimizedViewRegistryOnAndroid();
useOptimizedViewRegistryOnAndroid_ = flagValue;
@@ -1532,7 +1514,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(83, "useSharedAnimatedBackend");
markFlagAsAccessed(82, "useSharedAnimatedBackend");
flagValue = currentProvider_->useSharedAnimatedBackend();
useSharedAnimatedBackend_ = flagValue;
@@ -1550,7 +1532,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(84, "useTraitHiddenOnAndroid");
markFlagAsAccessed(83, "useTraitHiddenOnAndroid");
flagValue = currentProvider_->useTraitHiddenOnAndroid();
useTraitHiddenOnAndroid_ = flagValue;
@@ -1568,7 +1550,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(85, "useTurboModuleInterop");
markFlagAsAccessed(84, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -1586,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(86, "useTurboModules");
markFlagAsAccessed(85, "useTurboModules");
flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
@@ -1604,7 +1586,7 @@ bool ReactNativeFeatureFlagsAccessor::useUnorderedMapInDifferentiator() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(87, "useUnorderedMapInDifferentiator");
markFlagAsAccessed(86, "useUnorderedMapInDifferentiator");
flagValue = currentProvider_->useUnorderedMapInDifferentiator();
useUnorderedMapInDifferentiator_ = flagValue;
@@ -1622,7 +1604,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(88, "viewCullingOutsetRatio");
markFlagAsAccessed(87, "viewCullingOutsetRatio");
flagValue = currentProvider_->viewCullingOutsetRatio();
viewCullingOutsetRatio_ = flagValue;
@@ -1640,7 +1622,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(89, "viewTransitionEnabled");
markFlagAsAccessed(88, "viewTransitionEnabled");
flagValue = currentProvider_->viewTransitionEnabled();
viewTransitionEnabled_ = flagValue;
@@ -1658,7 +1640,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(90, "viewTransitionUseHardwareBitmapAndroid");
markFlagAsAccessed(89, "viewTransitionUseHardwareBitmapAndroid");
flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid();
viewTransitionUseHardwareBitmapAndroid_ = flagValue;
@@ -1676,7 +1658,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(91, "virtualViewPrerenderRatio");
markFlagAsAccessed(90, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -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<<8a068641229a3fbbe105a5368ea6bda9>>
* @generated SignedSource<<fbb0a9d8d259d57a93c99aecc5dffc29>>
*/
/**
@@ -86,7 +86,6 @@ class ReactNativeFeatureFlagsAccessor {
bool enableVirtualViewContainerStateExperimental();
bool enableVirtualViewDebugFeatures();
bool fixDifferentiatorParentTagForUnflattenCase();
bool fixFindShadowNodeByTagRaceCondition();
bool fixMappingOfEventPrioritiesBetweenFabricAndReact();
bool fixYogaFlexBasisFitContentInMainAxis();
bool fuseboxAssertSingleHostState();
@@ -135,7 +134,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 92> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 91> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -191,7 +190,6 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableVirtualViewContainerStateExperimental_;
std::atomic<std::optional<bool>> enableVirtualViewDebugFeatures_;
std::atomic<std::optional<bool>> fixDifferentiatorParentTagForUnflattenCase_;
std::atomic<std::optional<bool>> fixFindShadowNodeByTagRaceCondition_;
std::atomic<std::optional<bool>> fixMappingOfEventPrioritiesBetweenFabricAndReact_;
std::atomic<std::optional<bool>> fixYogaFlexBasisFitContentInMainAxis_;
std::atomic<std::optional<bool>> fuseboxAssertSingleHostState_;
@@ -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<<7be26fb138e59ef3dc34cec13d3813c4>>
* @generated SignedSource<<ce4fca61f4921c53df807ac40624f271>>
*/
/**
@@ -243,10 +243,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool fixFindShadowNodeByTagRaceCondition() override {
return false;
}
bool fixMappingOfEventPrioritiesBetweenFabricAndReact() override {
return false;
}
@@ -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<<2ea91689e8761dc57bc35975d1161839>>
* @generated SignedSource<<2a2318da48b2d84076bea7d5be491da5>>
*/
/**
@@ -531,15 +531,6 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::fixDifferentiatorParentTagForUnflattenCase();
}
bool fixFindShadowNodeByTagRaceCondition() override {
auto value = values_["fixFindShadowNodeByTagRaceCondition"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::fixFindShadowNodeByTagRaceCondition();
}
bool fixMappingOfEventPrioritiesBetweenFabricAndReact() override {
auto value = values_["fixMappingOfEventPrioritiesBetweenFabricAndReact"];
if (!value.isNull()) {
@@ -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<<60fc10a6c06d8381177c7c4dbd488dd9>>
* @generated SignedSource<<223fe2f5fdafc07ab2c98ccc24bc8b0b>>
*/
/**
@@ -79,7 +79,6 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableVirtualViewContainerStateExperimental() = 0;
virtual bool enableVirtualViewDebugFeatures() = 0;
virtual bool fixDifferentiatorParentTagForUnflattenCase() = 0;
virtual bool fixFindShadowNodeByTagRaceCondition() = 0;
virtual bool fixMappingOfEventPrioritiesBetweenFabricAndReact() = 0;
virtual bool fixYogaFlexBasisFitContentInMainAxis() = 0;
virtual bool fuseboxAssertSingleHostState() = 0;
@@ -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<<4deb82376e94d28a1d1775930ece1ccd>>
* @generated SignedSource<<f741aa24d86972d4a681676d2e13c768>>
*/
/**
@@ -314,11 +314,6 @@ bool NativeReactNativeFeatureFlags::fixDifferentiatorParentTagForUnflattenCase(
return ReactNativeFeatureFlags::fixDifferentiatorParentTagForUnflattenCase();
}
bool NativeReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition();
}
bool NativeReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
@@ -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<<1bc2c347fb241190b4ae048e12c5a885>>
* @generated SignedSource<<a3f35f8654cfa6130bb40bfd8f57ce17>>
*/
/**
@@ -144,8 +144,6 @@ class NativeReactNativeFeatureFlags
bool fixDifferentiatorParentTagForUnflattenCase(jsi::Runtime& runtime);
bool fixFindShadowNodeByTagRaceCondition(jsi::Runtime& runtime);
bool fixMappingOfEventPrioritiesBetweenFabricAndReact(jsi::Runtime& runtime);
bool fixYogaFlexBasisFitContentInMainAxis(jsi::Runtime& runtime);
@@ -539,30 +539,8 @@ std::shared_ptr<const ShadowNode> UIManager::findShadowNodeByTag_DEPRECATED(
auto shadowNode = std::shared_ptr<const ShadowNode>{};
shadowTreeRegistry_.enumerate([&](const ShadowTree& shadowTree, bool& stop) {
// Obtain a pointer to the root node. The flag-gated path uses
// getCurrentRevision() which keeps the root alive via shared_ptr for
// the entire traversal, fixing a use-after-free race condition.
RootShadowNode::Shared rootShadowNodeHolder;
const RootShadowNode* rootShadowNode = nullptr;
if (ReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition()) {
rootShadowNodeHolder = shadowTree.getCurrentRevision().rootShadowNode;
rootShadowNode = rootShadowNodeHolder.get();
} else {
// TODO(T257154369): Remove after flag rollout.
// The public interface of `ShadowTree` discourages accessing a stored
// pointer to a root node because of the possible data race.
// To work around this, we ask for a commit and immediately cancel it
// returning `nullptr` instead of a new shadow tree.
// We don't want to add a way to access a stored pointer to a root
// node because this `findShadowNodeByTag` is deprecated. It is only
// added to make migration to the new architecture easier.
shadowTree.tryCommit(
[&](const RootShadowNode& oldRootShadowNode) {
rootShadowNode = &oldRootShadowNode;
return nullptr;
},
{/* default commit options */});
}
auto rootShadowNodeHolder = shadowTree.getCurrentRevision().rootShadowNode;
const auto* rootShadowNode = rootShadowNodeHolder.get();
if (rootShadowNode != nullptr) {
const auto& children = rootShadowNode->getChildren();
@@ -11,8 +11,6 @@
#include <gtest/gtest.h>
#include <jsi/jsi.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
#include <react/renderer/core/ShadowNodeFragment.h>
#include <react/renderer/element/Element.h>
#include <react/renderer/element/testUtils.h>
@@ -20,20 +18,9 @@
namespace facebook::react {
class FindShadowNodeByTagTestFeatureFlags
: public ReactNativeFeatureFlagsDefaults {
public:
bool fixFindShadowNodeByTagRaceCondition() override {
return true;
}
};
class FindShadowNodeByTagTest : public ::testing::Test {
public:
FindShadowNodeByTagTest() {
ReactNativeFeatureFlags::override(
std::make_unique<FindShadowNodeByTagTestFeatureFlags>());
contextContainer_ = std::make_shared<ContextContainer>();
ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
@@ -66,7 +53,6 @@ class FindShadowNodeByTagTest : public ::testing::Test {
if (!surfaceStopped_) {
uiManager_->stopSurface(surfaceId_);
}
ReactNativeFeatureFlags::dangerouslyReset();
}
protected:
@@ -167,43 +153,6 @@ TEST_F(FindShadowNodeByTagTest, FindNonExistentNode) {
EXPECT_EQ(found, nullptr);
}
TEST_F(
FindShadowNodeByTagTest,
RawPointerFromTryCommitDanglesAfterSurfaceStop) {
// Observe root lifetime via weak_ptr
std::weak_ptr<const RootShadowNode> weakRoot;
{
auto rev = shadowTreePtr_->getCurrentRevision();
weakRoot = rev.rootShadowNode;
}
ASSERT_FALSE(weakRoot.expired());
// Simulate the old (buggy) pattern: capture raw pointer via tryCommit.
// This is exactly what findShadowNodeByTag_DEPRECATED used to do.
const RootShadowNode* rawPtr = nullptr;
shadowTreePtr_->tryCommit(
[&](const RootShadowNode& oldRoot) {
rawPtr = &oldRoot;
return nullptr; // cancel commit
},
{});
ASSERT_NE(rawPtr, nullptr);
ASSERT_EQ(rawPtr, weakRoot.lock().get());
// Stop the surface — releases all internal references (ShadowTree's
// currentRevision_ and MountingCoordinator's baseRevision_)
{
auto tree = uiManager_->stopSurface(surfaceId_);
surfaceStopped_ = true;
// tree goes out of scope here, destroying ShadowTree + MountingCoordinator
}
// Old root is now destroyed. rawPtr is dangling.
EXPECT_TRUE(weakRoot.expired())
<< "Old root should be destroyed after surface stop, "
"proving that the raw pointer captured from tryCommit is dangling";
}
TEST_F(FindShadowNodeByTagTest, SharedPtrFromRevisionSurvivesSurfaceStop) {
// The fixed pattern: getCurrentRevision() returns a shared_ptr copy
auto revision = shadowTreePtr_->getCurrentRevision();
@@ -623,17 +623,6 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
fixFindShadowNodeByTagRaceCondition: {
defaultValue: false,
metadata: {
dateAdded: '2026-02-25',
description:
'Fix a use-after-free race condition in findShadowNodeByTag_DEPRECATED by using getCurrentRevision() instead of tryCommit() with a raw pointer.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
fixMappingOfEventPrioritiesBetweenFabricAndReact: {
defaultValue: false,
metadata: {
@@ -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<<361b1ff3430ffad98aaf24bea3824208>>
* @generated SignedSource<<7bfc94d9e70103821d872c31927a7658>>
* @flow strict
* @noformat
*/
@@ -100,7 +100,6 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
enableVirtualViewContainerStateExperimental: Getter<boolean>,
enableVirtualViewDebugFeatures: Getter<boolean>,
fixDifferentiatorParentTagForUnflattenCase: Getter<boolean>,
fixFindShadowNodeByTagRaceCondition: Getter<boolean>,
fixMappingOfEventPrioritiesBetweenFabricAndReact: Getter<boolean>,
fixYogaFlexBasisFitContentInMainAxis: Getter<boolean>,
fuseboxAssertSingleHostState: Getter<boolean>,
@@ -415,10 +414,6 @@ export const enableVirtualViewDebugFeatures: Getter<boolean> = createNativeFlagG
* Fix incorrect parentTag passed as parentTagForUpdate in the unflatten-unflatten branch of calculateShadowViewMutationsFlattener, which causes UPDATE mutations to reference a parent being created in the same batch.
*/
export const fixDifferentiatorParentTagForUnflattenCase: Getter<boolean> = createNativeFlagGetter('fixDifferentiatorParentTagForUnflattenCase', false);
/**
* Fix a use-after-free race condition in findShadowNodeByTag_DEPRECATED by using getCurrentRevision() instead of tryCommit() with a raw pointer.
*/
export const fixFindShadowNodeByTagRaceCondition: Getter<boolean> = createNativeFlagGetter('fixFindShadowNodeByTagRaceCondition', false);
/**
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
*/
@@ -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<<69bfd288593aebd59355309a7777cd79>>
* @generated SignedSource<<4ec4c0d0f1055b2d39d8aa42d68c0a77>>
* @flow strict
* @noformat
*/
@@ -79,7 +79,6 @@ export interface Spec extends TurboModule {
+enableVirtualViewContainerStateExperimental?: () => boolean;
+enableVirtualViewDebugFeatures?: () => boolean;
+fixDifferentiatorParentTagForUnflattenCase?: () => boolean;
+fixFindShadowNodeByTagRaceCondition?: () => boolean;
+fixMappingOfEventPrioritiesBetweenFabricAndReact?: () => boolean;
+fixYogaFlexBasisFitContentInMainAxis?: () => boolean;
+fuseboxAssertSingleHostState?: () => boolean;