From 95b21b48282ebfc43b90d33e08df9b75d411fe5c Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 8 Nov 2018 16:55:12 -0800 Subject: [PATCH] Refactor 'induce' of events in Fabric Android Summary: This diff refactors the exeuction of 'AsyncEventBeat.induce()' as part of the delivery of events of Fabric Android implementation. The first part of the refactor moves the exeuction of onBatchEventDispatched out of the synchronization block for mEventsToDispatchLock. This lock is accessed from the UI Thread and executing the induce inside this synchronization block will affect UI, The second part of the refactor is to ensure that the exeuction of the C++ method AsyncEventBeat.induce() always happen in the JS Thread. Reviewed By: shergin Differential Revision: D12861387 fbshipit-source-id: e1cd03467274a1c5fcd04b0ac7efdbe7169b14c3 --- .../facebook/react/uimanager/events/EventDispatcher.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcher.java index f8506c8aa..720b1dcea 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcher.java @@ -365,12 +365,12 @@ public class EventDispatcher implements LifecycleEventListener { event.dispatch(mReactEventEmitter); event.dispose(); } - for (BatchEventDispatchedListener listener : mPostEventDispatchListeners) { - listener.onBatchEventDispatched(); - } clearEventsToDispatch(); mEventCookieToLastEventIdx.clear(); } + for (BatchEventDispatchedListener listener : mPostEventDispatchListeners) { + listener.onBatchEventDispatched(); + } } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); }