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 7523a99a7d306e..574346f475b20c 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 @@ -331,14 +331,11 @@ public void clearJSResponder() { @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); } /** @@ -458,11 +455,21 @@ public void enqueuePendingEvent( 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)); + } }