Skip to content

Commit 90a93aa

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
fix incorrect parentTag coming from differentiator when reparenting (facebook#50842)
Summary: Pull Request resolved: facebook#50842 changelog: [internal] introduce a feature flag that fixes incorrect parentTag coming from differentiator when reparenting. The problem occurs under very specific circumstances that are covered by an integration test. The *parentTag* is also [only used on Android](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp#L566) and only if layout changes as part of the update. This diff introduces a new test specifically triggering the incorrect behaviour: `Differentiator-itest.js`. Without this fix, the test fails on following assert: [react_native_assert(hasTag(mutation.parentTag))](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/renderer/mounting/stubs/StubViewTree.cpp#L245). This diff also converts existing tests for the differentiator to parametrised tests and enables the fix. Reviewed By: rubennorte Differential Revision: D73428312 fbshipit-source-id: 8b00977b610a85fba8b01a50a151f30bd5321ed4
1 parent 12def6d commit 90a93aa

25 files changed

+369
-87
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<<8a0be46378bf8810ac52a44024bfd587>>
7+
* @generated SignedSource<<a482d8bfae45b34898278328a0eb20c0>>
88
*/
99

1010
/**
@@ -102,6 +102,12 @@ public object ReactNativeFeatureFlags {
102102
@JvmStatic
103103
public fun enableFabricRenderer(): Boolean = accessor.enableFabricRenderer()
104104

105+
/**
106+
* This feature flag enables a fix for reparenting fix in differentiator
107+
*/
108+
@JvmStatic
109+
public fun enableFixForParentTagDuringReparenting(): Boolean = accessor.enableFixForParentTagDuringReparenting()
110+
105111
/**
106112
* Enables font scale changes updating layout for measurable nodes.
107113
*/

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<<5e462e70ca55296d1651678a7243508f>>
7+
* @generated SignedSource<<cb75c549c17f6a8fe5036f0c5babc5ca>>
88
*/
99

1010
/**
@@ -32,6 +32,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
3232
private var enableEagerRootViewAttachmentCache: Boolean? = null
3333
private var enableFabricLogsCache: Boolean? = null
3434
private var enableFabricRendererCache: Boolean? = null
35+
private var enableFixForParentTagDuringReparentingCache: Boolean? = null
3536
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
3637
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
3738
private var enableJSRuntimeGCOnMemoryPressureOnIOSCache: Boolean? = null
@@ -170,6 +171,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
170171
return cached
171172
}
172173

174+
override fun enableFixForParentTagDuringReparenting(): Boolean {
175+
var cached = enableFixForParentTagDuringReparentingCache
176+
if (cached == null) {
177+
cached = ReactNativeFeatureFlagsCxxInterop.enableFixForParentTagDuringReparenting()
178+
enableFixForParentTagDuringReparentingCache = cached
179+
}
180+
return cached
181+
}
182+
173183
override fun enableFontScaleChangesUpdatingLayout(): Boolean {
174184
var cached = enableFontScaleChangesUpdatingLayoutCache
175185
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<<f72540f3d9ad5f95ff3991e096a72c97>>
7+
* @generated SignedSource<<f24ac028449dd09db4e6fc325d2d1bd4>>
88
*/
99

1010
/**
@@ -52,6 +52,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
5252

5353
@DoNotStrip @JvmStatic public external fun enableFabricRenderer(): Boolean
5454

55+
@DoNotStrip @JvmStatic public external fun enableFixForParentTagDuringReparenting(): Boolean
56+
5557
@DoNotStrip @JvmStatic public external fun enableFontScaleChangesUpdatingLayout(): Boolean
5658

5759
@DoNotStrip @JvmStatic public external fun enableIOSViewClipToPaddingBox(): 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<<d123160bb9ffbc3b82b06ad2513a69c6>>
7+
* @generated SignedSource<<c99bff5f6032951601f6439c79cdbffd>>
88
*/
99

1010
/**
@@ -47,6 +47,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
4747

4848
override fun enableFabricRenderer(): Boolean = false
4949

50+
override fun enableFixForParentTagDuringReparenting(): Boolean = false
51+
5052
override fun enableFontScaleChangesUpdatingLayout(): Boolean = false
5153

5254
override fun enableIOSViewClipToPaddingBox(): 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<<9ef4812c333ca4fa1b05c66d0c59e303>>
7+
* @generated SignedSource<<a80e0caafa18fc7ce4f889f7f9cc4373>>
88
*/
99

1010
/**
@@ -36,6 +36,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3636
private var enableEagerRootViewAttachmentCache: Boolean? = null
3737
private var enableFabricLogsCache: Boolean? = null
3838
private var enableFabricRendererCache: Boolean? = null
39+
private var enableFixForParentTagDuringReparentingCache: Boolean? = null
3940
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
4041
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
4142
private var enableJSRuntimeGCOnMemoryPressureOnIOSCache: Boolean? = null
@@ -186,6 +187,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
186187
return cached
187188
}
188189

190+
override fun enableFixForParentTagDuringReparenting(): Boolean {
191+
var cached = enableFixForParentTagDuringReparentingCache
192+
if (cached == null) {
193+
cached = currentProvider.enableFixForParentTagDuringReparenting()
194+
accessedFeatureFlags.add("enableFixForParentTagDuringReparenting")
195+
enableFixForParentTagDuringReparentingCache = cached
196+
}
197+
return cached
198+
}
199+
189200
override fun enableFontScaleChangesUpdatingLayout(): Boolean {
190201
var cached = enableFontScaleChangesUpdatingLayoutCache
191202
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<<f3f828ba38e2b88b94a30234c46da607>>
7+
* @generated SignedSource<<76da11369c2f7b8955a154a63af374a3>>
88
*/
99

1010
/**
@@ -47,6 +47,8 @@ public interface ReactNativeFeatureFlagsProvider {
4747

4848
@DoNotStrip public fun enableFabricRenderer(): Boolean
4949

50+
@DoNotStrip public fun enableFixForParentTagDuringReparenting(): Boolean
51+
5052
@DoNotStrip public fun enableFontScaleChangesUpdatingLayout(): Boolean
5153

5254
@DoNotStrip public fun enableIOSViewClipToPaddingBox(): 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<<37e6ac5e48af0510ba8268e682379b95>>
7+
* @generated SignedSource<<e877dbd11729fd955f1e04c8436a47af>>
88
*/
99

1010
/**
@@ -111,6 +111,12 @@ class ReactNativeFeatureFlagsJavaProvider
111111
return method(javaProvider_);
112112
}
113113

114+
bool enableFixForParentTagDuringReparenting() override {
115+
static const auto method =
116+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFixForParentTagDuringReparenting");
117+
return method(javaProvider_);
118+
}
119+
114120
bool enableFontScaleChangesUpdatingLayout() override {
115121
static const auto method =
116122
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFontScaleChangesUpdatingLayout");
@@ -349,6 +355,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableFabricRenderer(
349355
return ReactNativeFeatureFlags::enableFabricRenderer();
350356
}
351357

358+
bool JReactNativeFeatureFlagsCxxInterop::enableFixForParentTagDuringReparenting(
359+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
360+
return ReactNativeFeatureFlags::enableFixForParentTagDuringReparenting();
361+
}
362+
352363
bool JReactNativeFeatureFlagsCxxInterop::enableFontScaleChangesUpdatingLayout(
353364
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
354365
return ReactNativeFeatureFlags::enableFontScaleChangesUpdatingLayout();
@@ -561,6 +572,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
561572
makeNativeMethod(
562573
"enableFabricRenderer",
563574
JReactNativeFeatureFlagsCxxInterop::enableFabricRenderer),
575+
makeNativeMethod(
576+
"enableFixForParentTagDuringReparenting",
577+
JReactNativeFeatureFlagsCxxInterop::enableFixForParentTagDuringReparenting),
564578
makeNativeMethod(
565579
"enableFontScaleChangesUpdatingLayout",
566580
JReactNativeFeatureFlagsCxxInterop::enableFontScaleChangesUpdatingLayout),

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<<c033d63bb3902999b30670f0ff47e8e5>>
7+
* @generated SignedSource<<e0ca5927c65c857463973df1f34f4b9d>>
88
*/
99

1010
/**
@@ -66,6 +66,9 @@ class JReactNativeFeatureFlagsCxxInterop
6666
static bool enableFabricRenderer(
6767
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
6868

69+
static bool enableFixForParentTagDuringReparenting(
70+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
71+
6972
static bool enableFontScaleChangesUpdatingLayout(
7073
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
7174

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<<e23f3826faf91b307440e3a9625014b8>>
7+
* @generated SignedSource<<5ee10cdf8f5e3695ce4f73373291935e>>
88
*/
99

1010
/**
@@ -74,6 +74,10 @@ bool ReactNativeFeatureFlags::enableFabricRenderer() {
7474
return getAccessor().enableFabricRenderer();
7575
}
7676

77+
bool ReactNativeFeatureFlags::enableFixForParentTagDuringReparenting() {
78+
return getAccessor().enableFixForParentTagDuringReparenting();
79+
}
80+
7781
bool ReactNativeFeatureFlags::enableFontScaleChangesUpdatingLayout() {
7882
return getAccessor().enableFontScaleChangesUpdatingLayout();
7983
}

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<<4555ff8492c6f12e623f8e5b0cd9f833>>
7+
* @generated SignedSource<<c3b70d43d96674bcd908c8e595df321e>>
88
*/
99

1010
/**
@@ -99,6 +99,11 @@ class ReactNativeFeatureFlags {
9999
*/
100100
RN_EXPORT static bool enableFabricRenderer();
101101

102+
/**
103+
* This feature flag enables a fix for reparenting fix in differentiator
104+
*/
105+
RN_EXPORT static bool enableFixForParentTagDuringReparenting();
106+
102107
/**
103108
* Enables font scale changes updating layout for measurable nodes.
104109
*/

0 commit comments

Comments
 (0)