From 472e0e4a3c2c51ea189d156373eedf5eb47604b7 Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Wed, 8 Jun 2022 14:19:01 -0700 Subject: [PATCH] Make sure we only queue events when event emitter is null Summary: This diff adds an assertion to make sure the pending events are enqueued only when the event emitter is null. This is to avoid unexpected workflow when we queue events but we should just dispatch them. Changelog: [Android][Internal] - Make sure we only queue events when event emitter is null Reviewed By: javache Differential Revision: D36916482 fbshipit-source-id: fff305615b302ece26bc2482c826b74de4f70266 --- .../react/fabric/mounting/SurfaceMountingManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 66f11b1a873..96dcb33cc18 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -1103,6 +1103,10 @@ public class SurfaceMountingManager { // Cannot queue event without view state. Do nothing here. return; } + Assertions.assertCondition( + viewState.mEventEmitter == null, + "Only queue pending events when event emitter is null for the given view state"); + if (viewState.mPendingEventQueue == null) { viewState.mPendingEventQueue = new LinkedList<>(); }