Skip to content

Commit b1bbe1e

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix execution of early InteropEvents (#48823)
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 b1bbe1e

File tree

1 file changed

+11
-8
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 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,17 @@ public void enqueuePendingEvent(
458455
boolean canCoalesceEvent,
459456
@Nullable WritableMap params,
460457
@EventCategoryDef int eventCategory) {
461-
@Nullable SurfaceMountingManager smm = getSurfaceManager(surfaceId);
458+
SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag);
459+
// Cannot queue event without valid surface mounting manager. Do nothing here.
462460
if (smm == null) {
463-
// Cannot queue event without valid surface mountng manager. Do nothing here.
464461
return;
465462
}
466463
smm.enqueuePendingEvent(reactTag, eventName, canCoalesceEvent, params, eventCategory);
467464
}
465+
466+
private @Nullable SurfaceMountingManager getSurfaceMountingManager(int surfaceId, int reactTag) {
467+
return (surfaceId == ViewUtil.NO_SURFACE_ID
468+
? getSurfaceManagerForView(reactTag)
469+
: getSurfaceManager(surfaceId));
470+
}
468471
}

0 commit comments

Comments
 (0)