Skip to content

Commit f2964e1

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Add feature flag to perform gesture sweep in JSTouchDispatcher (#52972)
Summary: Pull Request resolved: #52972 Fabric retains views by ID when `JSTouchDispatcher` receives a touch event, but does not sweep these same views if a child native gesture is started between the `ACTION_DOWN` and `ACTION_UP` actions of the touch. As a result, we never end up calling into that view's manager's `onDropViewInstance` method and can't perform reliable teardown of the view since it's stuck in this "touched" state. This is the first of a few changes to add a new feature flag `sweepActiveTouchOnChildNativeGesturesAndroid` to allow the `JSTouchDispatcher` to sweep active touches when a child native gesture is started. Running experiments internally to confirm that there are no unintended side effects from flushing the active touch. Changelog: [Internal] Reviewed By: jehartzog Differential Revision: D79257465 fbshipit-source-id: 1ca79e77b21d8086c4df6753b16b1d8d922cd8d5
1 parent 1b62d55 commit f2964e1

20 files changed

Lines changed: 150 additions & 33 deletions

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<<23d0b6132cde79fd2e82e329aec3ba97>>
7+
* @generated SignedSource<<2294f3350aca0f19862f8cfdbe9479b6>>
88
*/
99

1010
/**
@@ -354,6 +354,12 @@ public object ReactNativeFeatureFlags {
354354
@JvmStatic
355355
public fun skipActivityIdentityAssertionOnHostPause(): Boolean = accessor.skipActivityIdentityAssertionOnHostPause()
356356

357+
/**
358+
* A flag to tell Fabric to sweep active touches from JSTouchDispatcher in Android when a child native gesture is started.
359+
*/
360+
@JvmStatic
361+
public fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean = accessor.sweepActiveTouchOnChildNativeGesturesAndroid()
362+
357363
/**
358364
* Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause.
359365
*/

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<<de705ded06ca10697411e99c91903724>>
7+
* @generated SignedSource<<9f50b2fc5f4aad27e6cd8ecbde3d791a>>
88
*/
99

1010
/**
@@ -74,6 +74,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
7474
private var releaseImageDataWhenConsumedCache: Boolean? = null
7575
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
7676
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
77+
private var sweepActiveTouchOnChildNativeGesturesAndroidCache: Boolean? = null
7778
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
7879
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
7980
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
@@ -574,6 +575,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
574575
return cached
575576
}
576577

578+
override fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean {
579+
var cached = sweepActiveTouchOnChildNativeGesturesAndroidCache
580+
if (cached == null) {
581+
cached = ReactNativeFeatureFlagsCxxInterop.sweepActiveTouchOnChildNativeGesturesAndroid()
582+
sweepActiveTouchOnChildNativeGesturesAndroidCache = cached
583+
}
584+
return cached
585+
}
586+
577587
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
578588
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
579589
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<<59fecbad8533e88844ba114d49613794>>
7+
* @generated SignedSource<<27b8c102b60eadcf284fd3c156a037aa>>
88
*/
99

1010
/**
@@ -136,6 +136,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
136136

137137
@DoNotStrip @JvmStatic public external fun skipActivityIdentityAssertionOnHostPause(): Boolean
138138

139+
@DoNotStrip @JvmStatic public external fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean
140+
139141
@DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean
140142

141143
@DoNotStrip @JvmStatic public external fun updateRuntimeShadowNodeReferencesOnCommit(): 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<<275f6f2c36b2a0f7d83765d98ab60daf>>
7+
* @generated SignedSource<<9583365cd9d7786ee9be03ff34b0766f>>
88
*/
99

1010
/**
@@ -131,6 +131,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
131131

132132
override fun skipActivityIdentityAssertionOnHostPause(): Boolean = false
133133

134+
override fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean = false
135+
134136
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false
135137

136138
override fun updateRuntimeShadowNodeReferencesOnCommit(): 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<<acbbd313189620438b486593634a0523>>
7+
* @generated SignedSource<<8bcbcc20f92faf4c50c093fac701dfa2>>
88
*/
99

1010
/**
@@ -78,6 +78,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
7878
private var releaseImageDataWhenConsumedCache: Boolean? = null
7979
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
8080
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
81+
private var sweepActiveTouchOnChildNativeGesturesAndroidCache: Boolean? = null
8182
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
8283
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
8384
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
@@ -632,6 +633,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
632633
return cached
633634
}
634635

636+
override fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean {
637+
var cached = sweepActiveTouchOnChildNativeGesturesAndroidCache
638+
if (cached == null) {
639+
cached = currentProvider.sweepActiveTouchOnChildNativeGesturesAndroid()
640+
accessedFeatureFlags.add("sweepActiveTouchOnChildNativeGesturesAndroid")
641+
sweepActiveTouchOnChildNativeGesturesAndroidCache = cached
642+
}
643+
return cached
644+
}
645+
635646
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
636647
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
637648
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<<afd38d105b3b7ab92f98f39dbce40925>>
7+
* @generated SignedSource<<8a2403250a16c2b2b573fc05db6e4768>>
88
*/
99

1010
/**
@@ -131,6 +131,8 @@ public interface ReactNativeFeatureFlagsProvider {
131131

132132
@DoNotStrip public fun skipActivityIdentityAssertionOnHostPause(): Boolean
133133

134+
@DoNotStrip public fun sweepActiveTouchOnChildNativeGesturesAndroid(): Boolean
135+
134136
@DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean
135137

136138
@DoNotStrip public fun updateRuntimeShadowNodeReferencesOnCommit(): 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<<0d4e71457a51a22e6c8bb7315371bca8>>
7+
* @generated SignedSource<<72694e8b935e15e4b826a0174fd0c23f>>
88
*/
99

1010
/**
@@ -363,6 +363,12 @@ class ReactNativeFeatureFlagsJavaProvider
363363
return method(javaProvider_);
364364
}
365365

366+
bool sweepActiveTouchOnChildNativeGesturesAndroid() override {
367+
static const auto method =
368+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("sweepActiveTouchOnChildNativeGesturesAndroid");
369+
return method(javaProvider_);
370+
}
371+
366372
bool traceTurboModulePromiseRejectionsOnAndroid() override {
367373
static const auto method =
368374
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("traceTurboModulePromiseRejectionsOnAndroid");
@@ -715,6 +721,11 @@ bool JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPaus
715721
return ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause();
716722
}
717723

724+
bool JReactNativeFeatureFlagsCxxInterop::sweepActiveTouchOnChildNativeGesturesAndroid(
725+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
726+
return ReactNativeFeatureFlags::sweepActiveTouchOnChildNativeGesturesAndroid();
727+
}
728+
718729
bool JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid(
719730
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
720731
return ReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid();
@@ -973,6 +984,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
973984
makeNativeMethod(
974985
"skipActivityIdentityAssertionOnHostPause",
975986
JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause),
987+
makeNativeMethod(
988+
"sweepActiveTouchOnChildNativeGesturesAndroid",
989+
JReactNativeFeatureFlagsCxxInterop::sweepActiveTouchOnChildNativeGesturesAndroid),
976990
makeNativeMethod(
977991
"traceTurboModulePromiseRejectionsOnAndroid",
978992
JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid),

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<<10c4959f082ce75226ec975a6fe5b10c>>
7+
* @generated SignedSource<<90f0583b9d527a1291431a8318f10356>>
88
*/
99

1010
/**
@@ -192,6 +192,9 @@ class JReactNativeFeatureFlagsCxxInterop
192192
static bool skipActivityIdentityAssertionOnHostPause(
193193
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
194194

195+
static bool sweepActiveTouchOnChildNativeGesturesAndroid(
196+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
197+
195198
static bool traceTurboModulePromiseRejectionsOnAndroid(
196199
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
197200

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<<029a1d8d265538d6d48a2531ca4ca9df>>
7+
* @generated SignedSource<<6ff8aafa0de2f6c5cf8b42e0d43302e9>>
88
*/
99

1010
/**
@@ -242,6 +242,10 @@ bool ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause() {
242242
return getAccessor().skipActivityIdentityAssertionOnHostPause();
243243
}
244244

245+
bool ReactNativeFeatureFlags::sweepActiveTouchOnChildNativeGesturesAndroid() {
246+
return getAccessor().sweepActiveTouchOnChildNativeGesturesAndroid();
247+
}
248+
245249
bool ReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid() {
246250
return getAccessor().traceTurboModulePromiseRejectionsOnAndroid();
247251
}

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<<2baa48305074e8dce143fe6327ef719e>>
7+
* @generated SignedSource<<de9db1b4e8ad4d4a81368613a7d1cfb2>>
88
*/
99

1010
/**
@@ -309,6 +309,11 @@ class ReactNativeFeatureFlags {
309309
*/
310310
RN_EXPORT static bool skipActivityIdentityAssertionOnHostPause();
311311

312+
/**
313+
* A flag to tell Fabric to sweep active touches from JSTouchDispatcher in Android when a child native gesture is started.
314+
*/
315+
RN_EXPORT static bool sweepActiveTouchOnChildNativeGesturesAndroid();
316+
312317
/**
313318
* Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause.
314319
*/

0 commit comments

Comments
 (0)