Skip to content

Commit d8af0ae

Browse files
mdvaccarobhogan
authored andcommitted
Fix execution of early InteropEvents (facebook#48823)
Summary: Pull Request resolved: facebook#48823 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 Reviewed By: shwanton, lenaic Differential Revision: D68454811 fbshipit-source-id: a79be0b392004e645c48d1683bba774b6b597ca0
1 parent 83b986d commit d8af0ae

File tree

1 file changed

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

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,11 @@ public void clearJSResponder() {
330330
@AnyThread
331331
@ThreadConfined(ANY)
332332
public @Nullable EventEmitterWrapper getEventEmitter(int surfaceId, int reactTag) {
333-
SurfaceMountingManager surfaceMountingManager =
334-
(surfaceId == ViewUtil.NO_SURFACE_ID
335-
? getSurfaceManagerForView(reactTag)
336-
: getSurfaceManager(surfaceId));
337-
if (surfaceMountingManager == null) {
333+
SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag);
334+
if (smm == null) {
338335
return null;
339336
}
340-
return surfaceMountingManager.getEventEmitter(reactTag);
337+
return smm.getEventEmitter(reactTag);
341338
}
342339

343340
/**
@@ -434,11 +431,21 @@ public void enqueuePendingEvent(
434431
boolean canCoalesceEvent,
435432
@Nullable WritableMap params,
436433
@EventCategoryDef int eventCategory) {
437-
@Nullable SurfaceMountingManager smm = getSurfaceManager(surfaceId);
434+
SurfaceMountingManager smm = getSurfaceMountingManager(surfaceId, reactTag);
438435
if (smm == null) {
439-
// Cannot queue event without valid surface mountng manager. Do nothing here.
436+
FLog.d(
437+
TAG,
438+
"Cannot queue event without valid surface mounting manager for tag: %d, surfaceId: %d",
439+
reactTag,
440+
surfaceId);
440441
return;
441442
}
442443
smm.enqueuePendingEvent(reactTag, eventName, canCoalesceEvent, params, eventCategory);
443444
}
445+
446+
private @Nullable SurfaceMountingManager getSurfaceMountingManager(int surfaceId, int reactTag) {
447+
return (surfaceId == ViewUtil.NO_SURFACE_ID
448+
? getSurfaceManagerForView(reactTag)
449+
: getSurfaceManager(surfaceId));
450+
}
444451
}

0 commit comments

Comments
 (0)