Skip to content

Commit 903cd6a

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix execution of early InteropEvents
Summary: This diff is fixing the execution of Events that are sent early in the rendering of surfaces. This diff fixes a bug in the queueing of events that are built with not surfaceId (-1), the fixes is to call getSurfaceManagerForView() to retrieve the proper surfaceId (as we do in the execution of events) calling getSurfaceManagerForView() has a perf hit, we believe this won't be a problem because this method will only be called in edge cases (no surfaceId and early execution of events) changelog: [Android][Fixed] Fix execution of early InteropEvents Differential Revision: D68454811
1 parent 9afad52 commit 903cd6a

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,11 @@ public void clearJSResponder() {
331331
@AnyThread
332332
@ThreadConfined(ANY)
333333
public @Nullable EventEmitterWrapper getEventEmitter(int surfaceId, int reactTag) {
334-
SurfaceMountingManager surfaceMountingManager =
335-
(surfaceId == ViewUtil.NO_SURFACE_ID
336-
? getSurfaceManagerForView(reactTag)
337-
: getSurfaceManager(surfaceId));
338-
if (surfaceMountingManager == null) {
334+
SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag);
335+
if (smm == null) {
339336
return null;
340337
}
341-
return surfaceMountingManager.getEventEmitter(reactTag);
338+
return smm.getEventEmitter(reactTag);
342339
}
343340

344341
/**
@@ -458,11 +455,15 @@ public void enqueuePendingEvent(
458455
boolean canCoalesceEvent,
459456
@Nullable WritableMap params,
460457
@EventCategoryDef int eventCategory) {
461-
@Nullable SurfaceMountingManager smm = getSurfaceManager(surfaceId);
462-
if (smm == null) {
463-
// Cannot queue event without valid surface mountng manager. Do nothing here.
464-
return;
465-
}
458+
SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag);
459+
// Cannot queue event without valid surface mounting manager. Do nothing here.
460+
if (smm == null) return;
466461
smm.enqueuePendingEvent(reactTag, eventName, canCoalesceEvent, params, eventCategory);
467462
}
463+
464+
private @Nullable SurfaceMountingManager getSurfaceMountingManager(int surfaceId, int reactTag) {
465+
return (surfaceId == ViewUtil.NO_SURFACE_ID
466+
? getSurfaceManagerForView(reactTag)
467+
: getSurfaceManager(surfaceId));
468+
}
468469
}

0 commit comments

Comments
 (0)