From 9bc6c0f8a5cb779b9df394893cc097605dea37f6 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 10 Feb 2022 14:05:49 -0800 Subject: [PATCH] Fix UIManager detection in touch event emitter Summary: Certain events (practically always touch events probably?) will not be correctly emitted to JS in Fabric if there is no View underneath the touch - if there is no touch target besides the ReactRootView. We can just rely on the UIManagerType annotation on the Event, which is correct and reliable. Instead, what we do today is derive UIManagerType from ViewTag, which is correct UNLESS the viewtag is the same as the SurfaceId, in which case we may incorrectly detect that the touch is on a non-Fabric View when in fact it is on a Fabric ReactRootView. ViewTag is not a reliable way to detect Fabric vs non-Fabric /when looking at the RootView/, where ViewTag is the same as SurfaceId. Ironically, only Fabric RootViews have a SurfaceId at all. Practically, this won't change anything since events emitted to ReactRootView don't go anywhere (they don't have EventEmitters). So this is a pretty low-stakes fix, but is still technically correct. Changelog: [internal] Reviewed By: mdvacca Differential Revision: D34149878 fbshipit-source-id: f01da556865eb597a50cd49e9787316a0ed56f70 --- .../com/facebook/react/uimanager/events/ReactEventEmitter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java index a1eb560914b6e4..b1098cb0f63e04 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java @@ -86,7 +86,7 @@ public void receiveTouches( @Override public void receiveTouches(TouchEvent event) { int reactTag = event.getViewTag(); - @UIManagerType int uiManagerType = ViewUtil.getUIManagerType(reactTag); + @UIManagerType int uiManagerType = event.getUIManagerType(); if (uiManagerType == UIManagerType.FABRIC && mFabricEventEmitter != null) { mFabricEventEmitter.receiveTouches(event); } else if (uiManagerType == UIManagerType.DEFAULT && getEventEmitter(reactTag) != null) {