Skip to content

Commit 938bb33

Browse files
javachefacebook-github-bot
authored andcommitted
Fix differentiator emitting updates with incorrect parentTag (facebook#48055)
Summary: Address the test-case identified in D66557919, where Differentiator could emit updates for views referencing an incorrect parentTag. The longer-term fix here is to avoid emitting any updates for nodes which are being reparented, but that requires bigger changes, including to the LayoutAnimation system. As a short-term patch, we're passing through an explicit `parentShadowViewForUpdate` which will be used as the current parent for update purposes. {F1971278019} Changelog: [Android][Fixed] Fix Fabric mutations sometimes triggering a `getViewState` crash when referencing an invalid parentTag. Reviewed By: rubennorte Differential Revision: D66654293
1 parent 318db8e commit 938bb33

23 files changed

+183
-42
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6d8d8f4b81d7be882b315d0960499dcb>>
7+
* @generated SignedSource<<4a219bb47b1b9d988a164bca19eb4fa9>>
88
*/
99

1010
/**
@@ -202,6 +202,12 @@ public object ReactNativeFeatureFlags {
202202
@JvmStatic
203203
public fun excludeYogaFromRawProps(): Boolean = accessor.excludeYogaFromRawProps()
204204

205+
/**
206+
* Fixes a bug in Differentiator where parent views may be referenced before they're created
207+
*/
208+
@JvmStatic
209+
public fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean = accessor.fixDifferentiatorEmittingUpdatesWithWrongParentTag()
210+
205211
/**
206212
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
207213
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<031fce8e8b4c20a3e3d6dbecf94d138a>>
7+
* @generated SignedSource<<d75efd6beee8dd9d38b5d648fbecbcda>>
88
*/
99

1010
/**
@@ -49,6 +49,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
4949
private var enableUIConsistencyCache: Boolean? = null
5050
private var enableViewRecyclingCache: Boolean? = null
5151
private var excludeYogaFromRawPropsCache: Boolean? = null
52+
private var fixDifferentiatorEmittingUpdatesWithWrongParentTagCache: Boolean? = null
5253
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
5354
private var fixMountingCoordinatorReportedPendingTransactionsOnAndroidCache: Boolean? = null
5455
private var fuseboxEnabledDebugCache: Boolean? = null
@@ -328,6 +329,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
328329
return cached
329330
}
330331

332+
override fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean {
333+
var cached = fixDifferentiatorEmittingUpdatesWithWrongParentTagCache
334+
if (cached == null) {
335+
cached = ReactNativeFeatureFlagsCxxInterop.fixDifferentiatorEmittingUpdatesWithWrongParentTag()
336+
fixDifferentiatorEmittingUpdatesWithWrongParentTagCache = cached
337+
}
338+
return cached
339+
}
340+
331341
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
332342
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
333343
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<35811667ac2543e1f64e27bbdb483ec1>>
7+
* @generated SignedSource<<7454ab19a01cfbb0a54f14bd83fc3a90>>
88
*/
99

1010
/**
@@ -86,6 +86,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
8686

8787
@DoNotStrip @JvmStatic public external fun excludeYogaFromRawProps(): Boolean
8888

89+
@DoNotStrip @JvmStatic public external fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean
90+
8991
@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
9092

9193
@DoNotStrip @JvmStatic public external fun fixMountingCoordinatorReportedPendingTransactionsOnAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9d829c58e49164a0b2b6b66bc0ce088a>>
7+
* @generated SignedSource<<70d951b2956759280afae4af8f9a2869>>
88
*/
99

1010
/**
@@ -81,6 +81,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
8181

8282
override fun excludeYogaFromRawProps(): Boolean = false
8383

84+
override fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean = true
85+
8486
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
8587

8688
override fun fixMountingCoordinatorReportedPendingTransactionsOnAndroid(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<0121e113410a5b0e14eaf74a3076df2f>>
7+
* @generated SignedSource<<f60000cb58a9632c3aa193854be3de4e>>
88
*/
99

1010
/**
@@ -53,6 +53,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
5353
private var enableUIConsistencyCache: Boolean? = null
5454
private var enableViewRecyclingCache: Boolean? = null
5555
private var excludeYogaFromRawPropsCache: Boolean? = null
56+
private var fixDifferentiatorEmittingUpdatesWithWrongParentTagCache: Boolean? = null
5657
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
5758
private var fixMountingCoordinatorReportedPendingTransactionsOnAndroidCache: Boolean? = null
5859
private var fuseboxEnabledDebugCache: Boolean? = null
@@ -361,6 +362,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
361362
return cached
362363
}
363364

365+
override fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean {
366+
var cached = fixDifferentiatorEmittingUpdatesWithWrongParentTagCache
367+
if (cached == null) {
368+
cached = currentProvider.fixDifferentiatorEmittingUpdatesWithWrongParentTag()
369+
accessedFeatureFlags.add("fixDifferentiatorEmittingUpdatesWithWrongParentTag")
370+
fixDifferentiatorEmittingUpdatesWithWrongParentTagCache = cached
371+
}
372+
return cached
373+
}
374+
364375
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
365376
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
366377
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<2787d9027695dd14ec6b917a32a1a6de>>
7+
* @generated SignedSource<<d62af893c5d18a2152f098ff305ae41e>>
88
*/
99

1010
/**
@@ -81,6 +81,8 @@ public interface ReactNativeFeatureFlagsProvider {
8181

8282
@DoNotStrip public fun excludeYogaFromRawProps(): Boolean
8383

84+
@DoNotStrip public fun fixDifferentiatorEmittingUpdatesWithWrongParentTag(): Boolean
85+
8486
@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
8587

8688
@DoNotStrip public fun fixMountingCoordinatorReportedPendingTransactionsOnAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<902b269e45fcb4970c6f8a86818e1940>>
7+
* @generated SignedSource<<640630d7a40b53f7d507569aa6409f69>>
88
*/
99

1010
/**
@@ -213,6 +213,12 @@ class ReactNativeFeatureFlagsProviderHolder
213213
return method(javaProvider_);
214214
}
215215

216+
bool fixDifferentiatorEmittingUpdatesWithWrongParentTag() override {
217+
static const auto method =
218+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixDifferentiatorEmittingUpdatesWithWrongParentTag");
219+
return method(javaProvider_);
220+
}
221+
216222
bool fixMappingOfEventPrioritiesBetweenFabricAndReact() override {
217223
static const auto method =
218224
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixMappingOfEventPrioritiesBetweenFabricAndReact");
@@ -464,6 +470,11 @@ bool JReactNativeFeatureFlagsCxxInterop::excludeYogaFromRawProps(
464470
return ReactNativeFeatureFlags::excludeYogaFromRawProps();
465471
}
466472

473+
bool JReactNativeFeatureFlagsCxxInterop::fixDifferentiatorEmittingUpdatesWithWrongParentTag(
474+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
475+
return ReactNativeFeatureFlags::fixDifferentiatorEmittingUpdatesWithWrongParentTag();
476+
}
477+
467478
bool JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact(
468479
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
469480
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
@@ -667,6 +678,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
667678
makeNativeMethod(
668679
"excludeYogaFromRawProps",
669680
JReactNativeFeatureFlagsCxxInterop::excludeYogaFromRawProps),
681+
makeNativeMethod(
682+
"fixDifferentiatorEmittingUpdatesWithWrongParentTag",
683+
JReactNativeFeatureFlagsCxxInterop::fixDifferentiatorEmittingUpdatesWithWrongParentTag),
670684
makeNativeMethod(
671685
"fixMappingOfEventPrioritiesBetweenFabricAndReact",
672686
JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<17da0d7937c5c0c533293b86c8cdc9be>>
7+
* @generated SignedSource<<4218168e779a2241d0752771c1f51b12>>
88
*/
99

1010
/**
@@ -117,6 +117,9 @@ class JReactNativeFeatureFlagsCxxInterop
117117
static bool excludeYogaFromRawProps(
118118
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
119119

120+
static bool fixDifferentiatorEmittingUpdatesWithWrongParentTag(
121+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
122+
120123
static bool fixMappingOfEventPrioritiesBetweenFabricAndReact(
121124
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
122125

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<ef215623465d45c563030d724287b1c9>>
7+
* @generated SignedSource<<2409869111055ff0b32c1f40c10042d7>>
88
*/
99

1010
/**
@@ -142,6 +142,10 @@ bool ReactNativeFeatureFlags::excludeYogaFromRawProps() {
142142
return getAccessor().excludeYogaFromRawProps();
143143
}
144144

145+
bool ReactNativeFeatureFlags::fixDifferentiatorEmittingUpdatesWithWrongParentTag() {
146+
return getAccessor().fixDifferentiatorEmittingUpdatesWithWrongParentTag();
147+
}
148+
145149
bool ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact() {
146150
return getAccessor().fixMappingOfEventPrioritiesBetweenFabricAndReact();
147151
}

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<f741660e4cf2528defe0ab1f61858aab>>
7+
* @generated SignedSource<<e628af8109a1d8bb6425515d824852a3>>
88
*/
99

1010
/**
@@ -184,6 +184,11 @@ class ReactNativeFeatureFlags {
184184
*/
185185
RN_EXPORT static bool excludeYogaFromRawProps();
186186

187+
/**
188+
* Fixes a bug in Differentiator where parent views may be referenced before they're created
189+
*/
190+
RN_EXPORT static bool fixDifferentiatorEmittingUpdatesWithWrongParentTag();
191+
187192
/**
188193
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
189194
*/

0 commit comments

Comments
 (0)