Skip to content

Commit ba50032

Browse files
gate follow-up mount item dispatch behind enableFollowUpMountItemDispatchAndroid
1 parent d41e196 commit ba50032

23 files changed

Lines changed: 250 additions & 93 deletions

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ internal class MountItemDispatcher(
100100
// enqueued during dispatch (e.g., from synchronous state updates triggered by view layout)
101101
// are processed in the same frame rather than deferred to the next one.
102102
if (inDispatch) {
103-
followUpDispatchRequired = true
103+
if (ReactNativeFeatureFlags.enableFollowUpMountItemDispatchAndroid()) {
104+
followUpDispatchRequired = true
105+
}
104106
return
105107
}
106108

‎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<<a39494512e761e266940e5d1853f38fc>>
7+
* @generated SignedSource<<4171750cfc627709dcd32ccb67131dda>>
88
*/
99

1010
/**
@@ -192,6 +192,12 @@ public object ReactNativeFeatureFlags {
192192
@JvmStatic
193193
public fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = accessor.enableFlexboxAutoMinSizeInStrictMode()
194194

195+
/**
196+
* When mount items are queued while MountItemDispatcher is already dispatching on Android (e.g. from a synchronous state update), dispatch them in the same frame instead of deferring them to the next one.
197+
*/
198+
@JvmStatic
199+
public fun enableFollowUpMountItemDispatchAndroid(): Boolean = accessor.enableFollowUpMountItemDispatchAndroid()
200+
195201
/**
196202
* Enables font scale changes updating layout for measurable nodes.
197203
*/

‎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<<cd1753241fa2f51c23cd4e01ffe3f18c>>
7+
* @generated SignedSource<<7928e03a82c0fd05eb5a1623959402c4>>
88
*/
99

1010
/**
@@ -47,6 +47,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
4747
private var enableFabricCommitBranchingMergeOnMainThreadCache: Boolean? = null
4848
private var enableFabricLogsCache: Boolean? = null
4949
private var enableFlexboxAutoMinSizeInStrictModeCache: Boolean? = null
50+
private var enableFollowUpMountItemDispatchAndroidCache: Boolean? = null
5051
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
5152
private var enableIOSCompressedTextFrameAdjustmentCache: Boolean? = null
5253
private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null
@@ -353,6 +354,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
353354
return cached
354355
}
355356

357+
override fun enableFollowUpMountItemDispatchAndroid(): Boolean {
358+
var cached = enableFollowUpMountItemDispatchAndroidCache
359+
if (cached == null) {
360+
cached = ReactNativeFeatureFlagsCxxInterop.enableFollowUpMountItemDispatchAndroid()
361+
enableFollowUpMountItemDispatchAndroidCache = cached
362+
}
363+
return cached
364+
}
365+
356366
override fun enableFontScaleChangesUpdatingLayout(): Boolean {
357367
var cached = enableFontScaleChangesUpdatingLayoutCache
358368
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<<eb8737673aaec0b1eda6ae2ebc0b9970>>
7+
* @generated SignedSource<<893c2c5612cff8fe044bead40c2fc603>>
88
*/
99

1010
/**
@@ -82,6 +82,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
8282

8383
@DoNotStrip @JvmStatic public external fun enableFlexboxAutoMinSizeInStrictMode(): Boolean
8484

85+
@DoNotStrip @JvmStatic public external fun enableFollowUpMountItemDispatchAndroid(): Boolean
86+
8587
@DoNotStrip @JvmStatic public external fun enableFontScaleChangesUpdatingLayout(): Boolean
8688

8789
@DoNotStrip @JvmStatic public external fun enableIOSCompressedTextFrameAdjustment(): 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<<890e204b6cf8afef481f64de44766edf>>
7+
* @generated SignedSource<<0093c0cd89ab032619b8a77146af32ab>>
88
*/
99

1010
/**
@@ -77,6 +77,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
7777

7878
override fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = false
7979

80+
override fun enableFollowUpMountItemDispatchAndroid(): Boolean = false
81+
8082
override fun enableFontScaleChangesUpdatingLayout(): Boolean = true
8183

8284
override fun enableIOSCompressedTextFrameAdjustment(): 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<<9044f0df865ba9d7668f9ff391d21911>>
7+
* @generated SignedSource<<330c3dd9643d65d443d3fdc6ac71055e>>
88
*/
99

1010
/**
@@ -51,6 +51,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
5151
private var enableFabricCommitBranchingMergeOnMainThreadCache: Boolean? = null
5252
private var enableFabricLogsCache: Boolean? = null
5353
private var enableFlexboxAutoMinSizeInStrictModeCache: Boolean? = null
54+
private var enableFollowUpMountItemDispatchAndroidCache: Boolean? = null
5455
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
5556
private var enableIOSCompressedTextFrameAdjustmentCache: Boolean? = null
5657
private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null
@@ -384,6 +385,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
384385
return cached
385386
}
386387

388+
override fun enableFollowUpMountItemDispatchAndroid(): Boolean {
389+
var cached = enableFollowUpMountItemDispatchAndroidCache
390+
if (cached == null) {
391+
cached = currentProvider.enableFollowUpMountItemDispatchAndroid()
392+
accessedFeatureFlags.add("enableFollowUpMountItemDispatchAndroid")
393+
enableFollowUpMountItemDispatchAndroidCache = cached
394+
}
395+
return cached
396+
}
397+
387398
override fun enableFontScaleChangesUpdatingLayout(): Boolean {
388399
var cached = enableFontScaleChangesUpdatingLayoutCache
389400
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<<cfd99e53a077549124370e6bb123ba43>>
7+
* @generated SignedSource<<abedea0a0379547a304f85f8bc5b259b>>
88
*/
99

1010
/**
@@ -77,6 +77,8 @@ public interface ReactNativeFeatureFlagsProvider {
7777

7878
@DoNotStrip public fun enableFlexboxAutoMinSizeInStrictMode(): Boolean
7979

80+
@DoNotStrip public fun enableFollowUpMountItemDispatchAndroid(): Boolean
81+
8082
@DoNotStrip public fun enableFontScaleChangesUpdatingLayout(): Boolean
8183

8284
@DoNotStrip public fun enableIOSCompressedTextFrameAdjustment(): Boolean

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/StateWrapper.kt‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import com.facebook.react.common.mapbuffer.ReadableMapBuffer
1818
*/
1919
public interface StateWrapper {
2020
/**
21-
* Maps to EventQueue::UpdateMode in C++.
22-
* Controls how state updates are flushed (Async or Sync).
21+
* Maps to EventQueue::UpdateMode in C++. Controls how state updates are flushed (Async or Sync).
2322
*/
2423
public enum class UpdateMode(public val value: Int) {
2524
Asynchronous(0),
26-
unstable_Immediate(1)
25+
unstable_Immediate(1),
2726
}
2827

2928
/**
@@ -40,8 +39,7 @@ public interface StateWrapper {
4039

4140
/**
4241
* Pass a map of values back to the C++ layer. The operation is performed synchronously and cannot
43-
* fail.
44-
* updateMode controls whether the update is queued asynchronously or flushed immediately.
42+
* fail. updateMode controls whether the update is queued asynchronously or flushed immediately.
4543
*/
4644
public fun updateState(map: WritableMap, updateMode: UpdateMode = UpdateMode.Asynchronous)
4745

‎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<<e6f56d60147d5c08e0b38549b9956e52>>
7+
* @generated SignedSource<<251b3d06d3969eb89068403e3c07346e>>
88
*/
99

1010
/**
@@ -201,6 +201,12 @@ class ReactNativeFeatureFlagsJavaProvider
201201
return method(javaProvider_);
202202
}
203203

204+
bool enableFollowUpMountItemDispatchAndroid() override {
205+
static const auto method =
206+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFollowUpMountItemDispatchAndroid");
207+
return method(javaProvider_);
208+
}
209+
204210
bool enableFontScaleChangesUpdatingLayout() override {
205211
static const auto method =
206212
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFontScaleChangesUpdatingLayout");
@@ -712,6 +718,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableFlexboxAutoMinSizeInStrictMode(
712718
return ReactNativeFeatureFlags::enableFlexboxAutoMinSizeInStrictMode();
713719
}
714720

721+
bool JReactNativeFeatureFlagsCxxInterop::enableFollowUpMountItemDispatchAndroid(
722+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
723+
return ReactNativeFeatureFlags::enableFollowUpMountItemDispatchAndroid();
724+
}
725+
715726
bool JReactNativeFeatureFlagsCxxInterop::enableFontScaleChangesUpdatingLayout(
716727
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
717728
return ReactNativeFeatureFlags::enableFontScaleChangesUpdatingLayout();
@@ -1134,6 +1145,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11341145
makeNativeMethod(
11351146
"enableFlexboxAutoMinSizeInStrictMode",
11361147
JReactNativeFeatureFlagsCxxInterop::enableFlexboxAutoMinSizeInStrictMode),
1148+
makeNativeMethod(
1149+
"enableFollowUpMountItemDispatchAndroid",
1150+
JReactNativeFeatureFlagsCxxInterop::enableFollowUpMountItemDispatchAndroid),
11371151
makeNativeMethod(
11381152
"enableFontScaleChangesUpdatingLayout",
11391153
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<<25d66101785e737822e86d218789912d>>
7+
* @generated SignedSource<<913ddf4c8e4d0b4f897ff51e6d403b69>>
88
*/
99

1010
/**
@@ -111,6 +111,9 @@ class JReactNativeFeatureFlagsCxxInterop
111111
static bool enableFlexboxAutoMinSizeInStrictMode(
112112
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
113113

114+
static bool enableFollowUpMountItemDispatchAndroid(
115+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
116+
114117
static bool enableFontScaleChangesUpdatingLayout(
115118
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
116119

0 commit comments

Comments
 (0)