diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 3aa8c930349..6f0cca01c97 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -330,14 +330,11 @@ public class MountingManager { @AnyThread @ThreadConfined(ANY) public @Nullable EventEmitterWrapper getEventEmitter(int surfaceId, int reactTag) { - SurfaceMountingManager surfaceMountingManager = - (surfaceId == ViewUtil.NO_SURFACE_ID - ? getSurfaceManagerForView(reactTag) - : getSurfaceManager(surfaceId)); - if (surfaceMountingManager == null) { + SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag); + if (smm == null) { return null; } - return surfaceMountingManager.getEventEmitter(reactTag); + return smm.getEventEmitter(reactTag); } /** @@ -434,11 +431,21 @@ public class MountingManager { boolean canCoalesceEvent, @Nullable WritableMap params, @EventCategoryDef int eventCategory) { - @Nullable SurfaceMountingManager smm = getSurfaceManager(surfaceId); + SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag); if (smm == null) { - // Cannot queue event without valid surface mountng manager. Do nothing here. + FLog.d( + TAG, + "Cannot queue event without valid surface mounting manager for tag: %d, surfaceId: %d", + reactTag, + surfaceId); return; } smm.enqueuePendingEvent(reactTag, eventName, canCoalesceEvent, params, eventCategory); } + + private @Nullable SurfaceMountingManager getSurfaceMountingManager(int surfaceId, int reactTag) { + return (surfaceId == ViewUtil.NO_SURFACE_ID + ? getSurfaceManagerForView(reactTag) + : getSurfaceManager(surfaceId)); + } }