diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp index 9d37fa1f08cc1a..e3908c880dff71 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp @@ -23,7 +23,6 @@ void EventEmitterWrapper::dispatchEvent( eventEmitter->dispatchEvent( eventName, payload ? payload->consume() : folly::dynamic::object(), - EventPriority::AsynchronousBatched, static_cast(category)); } } diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp index 9ea8c939900431..016c3316bb418e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp @@ -94,14 +94,10 @@ void ScrollViewEventEmitter::onMomentumScrollEnd( void ScrollViewEventEmitter::dispatchScrollViewEvent( std::string name, - const ScrollViewMetrics& scrollViewMetrics, - EventPriority priority) const { - dispatchEvent( - std::move(name), - [scrollViewMetrics](jsi::Runtime& runtime) { - return scrollViewMetricsPayload(runtime, scrollViewMetrics); - }, - priority); + const ScrollViewMetrics& scrollViewMetrics) const { + dispatchEvent(std::move(name), [scrollViewMetrics](jsi::Runtime& runtime) { + return scrollViewMetricsPayload(runtime, scrollViewMetrics); + }); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h index 8a849db8a50935..12e271149149c0 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h @@ -38,8 +38,7 @@ class ScrollViewEventEmitter : public ViewEventEmitter { private: void dispatchScrollViewEvent( std::string name, - const ScrollViewMetrics& scrollViewMetrics, - EventPriority priority = EventPriority::AsynchronousBatched) const; + const ScrollViewMetrics& scrollViewMetrics) const; }; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp index 8f1bf5734add40..4b39a211fba349 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp @@ -114,12 +114,9 @@ void TextInputEventEmitter::onSubmitEditing( void TextInputEventEmitter::onKeyPress( const KeyPressMetrics& keyPressMetrics) const { - dispatchEvent( - "keyPress", - [keyPressMetrics](jsi::Runtime& runtime) { - return keyPressMetricsPayload(runtime, keyPressMetrics); - }, - EventPriority::AsynchronousBatched); + dispatchEvent("keyPress", [keyPressMetrics](jsi::Runtime& runtime) { + return keyPressMetricsPayload(runtime, keyPressMetrics); + }); } void TextInputEventEmitter::onScroll( @@ -129,26 +126,18 @@ void TextInputEventEmitter::onScroll( void TextInputEventEmitter::dispatchTextInputEvent( const std::string& name, - const TextInputMetrics& textInputMetrics, - EventPriority priority) const { - dispatchEvent( - name, - [textInputMetrics](jsi::Runtime& runtime) { - return textInputMetricsPayload(runtime, textInputMetrics); - }, - priority); + const TextInputMetrics& textInputMetrics) const { + dispatchEvent(name, [textInputMetrics](jsi::Runtime& runtime) { + return textInputMetricsPayload(runtime, textInputMetrics); + }); } void TextInputEventEmitter::dispatchTextInputContentSizeChangeEvent( const std::string& name, - const TextInputMetrics& textInputMetrics, - EventPriority priority) const { - dispatchEvent( - name, - [textInputMetrics](jsi::Runtime& runtime) { - return textInputMetricsContentSizePayload(runtime, textInputMetrics); - }, - priority); + const TextInputMetrics& textInputMetrics) const { + dispatchEvent(name, [textInputMetrics](jsi::Runtime& runtime) { + return textInputMetricsContentSizePayload(runtime, textInputMetrics); + }); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h index a4c68483c235b5..ba3e20e10584e2 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h @@ -49,13 +49,11 @@ class TextInputEventEmitter : public ViewEventEmitter { private: void dispatchTextInputEvent( const std::string& name, - const TextInputMetrics& textInputMetrics, - EventPriority priority = EventPriority::AsynchronousBatched) const; + const TextInputMetrics& textInputMetrics) const; void dispatchTextInputContentSizeChangeEvent( const std::string& name, - const TextInputMetrics& textInputMetrics, - EventPriority priority = EventPriority::AsynchronousBatched) const; + const TextInputMetrics& textInputMetrics) const; }; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp index 154273a830dfa3..d147e5db54112c 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp @@ -45,35 +45,25 @@ static jsi::Value touchEventPayload( void TouchEventEmitter::dispatchTouchEvent( std::string type, const TouchEvent& event, - EventPriority priority, RawEvent::Category category) const { dispatchEvent( std::move(type), [event](jsi::Runtime& runtime) { return touchEventPayload(runtime, event); }, - priority, category); } void TouchEventEmitter::dispatchPointerEvent( std::string type, const PointerEvent& event, - EventPriority priority, RawEvent::Category category) const { dispatchEvent( - std::move(type), - std::make_shared(event), - priority, - category); + std::move(type), std::make_shared(event), category); } void TouchEventEmitter::onTouchStart(const TouchEvent& event) const { - dispatchTouchEvent( - "touchStart", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + dispatchTouchEvent("touchStart", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onTouchMove(const TouchEvent& event) const { @@ -83,43 +73,25 @@ void TouchEventEmitter::onTouchMove(const TouchEvent& event) const { } void TouchEventEmitter::onTouchEnd(const TouchEvent& event) const { - dispatchTouchEvent( - "touchEnd", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + dispatchTouchEvent("touchEnd", event, RawEvent::Category::ContinuousEnd); } void TouchEventEmitter::onTouchCancel(const TouchEvent& event) const { - dispatchTouchEvent( - "touchCancel", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + dispatchTouchEvent("touchCancel", event, RawEvent::Category::ContinuousEnd); } void TouchEventEmitter::onClick(const PointerEvent& event) const { - dispatchPointerEvent( - "click", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::Discrete); + dispatchPointerEvent("click", event, RawEvent::Category::Discrete); } void TouchEventEmitter::onPointerCancel(const PointerEvent& event) const { dispatchPointerEvent( - "pointerCancel", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + "pointerCancel", event, RawEvent::Category::ContinuousEnd); } void TouchEventEmitter::onPointerDown(const PointerEvent& event) const { dispatchPointerEvent( - "pointerDown", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + "pointerDown", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onPointerMove(const PointerEvent& event) const { @@ -127,59 +99,37 @@ void TouchEventEmitter::onPointerMove(const PointerEvent& event) const { } void TouchEventEmitter::onPointerUp(const PointerEvent& event) const { - dispatchPointerEvent( - "pointerUp", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + dispatchPointerEvent("pointerUp", event, RawEvent::Category::ContinuousEnd); } void TouchEventEmitter::onPointerEnter(const PointerEvent& event) const { dispatchPointerEvent( - "pointerEnter", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + "pointerEnter", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onPointerLeave(const PointerEvent& event) const { dispatchPointerEvent( - "pointerLeave", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + "pointerLeave", event, RawEvent::Category::ContinuousEnd); } void TouchEventEmitter::onPointerOver(const PointerEvent& event) const { dispatchPointerEvent( - "pointerOver", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + "pointerOver", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onPointerOut(const PointerEvent& event) const { dispatchPointerEvent( - "pointerOut", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + "pointerOut", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onGotPointerCapture(const PointerEvent& event) const { dispatchPointerEvent( - "gotPointerCapture", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousStart); + "gotPointerCapture", event, RawEvent::Category::ContinuousStart); } void TouchEventEmitter::onLostPointerCapture(const PointerEvent& event) const { dispatchPointerEvent( - "lostPointerCapture", - event, - EventPriority::AsynchronousBatched, - RawEvent::Category::ContinuousEnd); + "lostPointerCapture", event, RawEvent::Category::ContinuousEnd); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.h index 08b368c0eb552d..869e3ac34054ba 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEventEmitter.h @@ -45,12 +45,10 @@ class TouchEventEmitter : public EventEmitter { void dispatchTouchEvent( std::string type, const TouchEvent& event, - EventPriority priority, RawEvent::Category category) const; void dispatchPointerEvent( std::string type, const PointerEvent& event, - EventPriority priority, RawEvent::Category category) const; }; diff --git a/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h b/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h index 6a0ab8daf2f0b2..4755dc875c7c02 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h @@ -58,16 +58,10 @@ class ConcreteState : public State { * function for cases where a new value of data does not depend on an old * value. */ - void updateState(Data&& newData, EventPriority priority) const { - updateState( - [data{std::move(newData)}](const Data& oldData) -> SharedData { - return std::make_shared(data); - }, - priority); - } - void updateState(Data&& newData) const { - updateState(std::move(newData), EventPriority::AsynchronousBatched); + updateState([data{std::move(newData)}](const Data& oldData) -> SharedData { + return std::make_shared(data); + }); } /* @@ -79,8 +73,7 @@ class ConcreteState : public State { * return `nullptr`. */ void updateState( - std::function callback, - EventPriority priority = EventPriority::AsynchronousBatched) const { + std::function callback) const { auto family = family_.lock(); if (!family) { @@ -95,7 +88,7 @@ class ConcreteState : public State { return callback(*static_cast(oldData.get())); }}; - family->dispatchRawState(std::move(stateUpdate), priority); + family->dispatchRawState(std::move(stateUpdate)); } #ifdef ANDROID diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp index e6385ae6d41403..14e675e9dc0a50 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -21,21 +21,11 @@ EventDispatcher::EventDispatcher( const EventBeat::Factory& synchonousEventBeatFactory, const EventBeat::Factory& asynchronousEventBeatFactory, const EventBeat::SharedOwnerBox& ownerBox) - : synchronousUnbatchedQueue_(std::make_unique( - eventProcessor, - synchonousEventBeatFactory(ownerBox))), - synchronousBatchedQueue_(std::make_unique( - eventProcessor, - synchonousEventBeatFactory(ownerBox))), - asynchronousUnbatchedQueue_(std::make_unique( - eventProcessor, - asynchronousEventBeatFactory(ownerBox))), - asynchronousBatchedQueue_(std::make_unique( + : asynchronousBatchedQueue_(std::make_unique( eventProcessor, asynchronousEventBeatFactory(ownerBox))) {} -void EventDispatcher::dispatchEvent(RawEvent&& rawEvent, EventPriority priority) - const { +void EventDispatcher::dispatchEvent(RawEvent&& rawEvent) const { // Allows the event listener to interrupt default event dispatch if (eventListeners_.willDispatchEvent(rawEvent)) { return; @@ -45,13 +35,11 @@ void EventDispatcher::dispatchEvent(RawEvent&& rawEvent, EventPriority priority) if (eventLogger != nullptr) { rawEvent.loggingTag = eventLogger->onEventStart(rawEvent.type); } - getEventQueue(priority).enqueueEvent(std::move(rawEvent)); + asynchronousBatchedQueue_->enqueueEvent(std::move(rawEvent)); } -void EventDispatcher::dispatchStateUpdate( - StateUpdate&& stateUpdate, - EventPriority priority) const { - getEventQueue(priority).enqueueStateUpdate(std::move(stateUpdate)); +void EventDispatcher::dispatchStateUpdate(StateUpdate&& stateUpdate) const { + asynchronousBatchedQueue_->enqueueStateUpdate(std::move(stateUpdate)); } void EventDispatcher::dispatchUniqueEvent(RawEvent&& rawEvent) const { @@ -62,19 +50,6 @@ void EventDispatcher::dispatchUniqueEvent(RawEvent&& rawEvent) const { asynchronousBatchedQueue_->enqueueUniqueEvent(std::move(rawEvent)); } -const EventQueue& EventDispatcher::getEventQueue(EventPriority priority) const { - switch (priority) { - case EventPriority::SynchronousUnbatched: - return *synchronousUnbatchedQueue_; - case EventPriority::SynchronousBatched: - return *synchronousBatchedQueue_; - case EventPriority::AsynchronousUnbatched: - return *asynchronousUnbatchedQueue_; - case EventPriority::AsynchronousBatched: - return *asynchronousBatchedQueue_; - } -} - void EventDispatcher::addListener( const std::shared_ptr& listener) const { eventListeners_.addListener(listener); diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h index 77594bfb877606..0fff56155d829f 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +36,7 @@ class EventDispatcher { /* * Dispatches a raw event with given priority using event-delivery pipe. */ - void dispatchEvent(RawEvent&& rawEvent, EventPriority priority) const; + void dispatchEvent(RawEvent&& rawEvent) const; /* * Dispatches a raw event with asynchronous batched priority. Before the @@ -49,8 +48,7 @@ class EventDispatcher { /* * Dispatches a state update with given priority. */ - void dispatchStateUpdate(StateUpdate&& stateUpdate, EventPriority priority) - const; + void dispatchStateUpdate(StateUpdate&& stateUpdate) const; #pragma mark - Event listeners /* @@ -65,11 +63,6 @@ class EventDispatcher { const std::shared_ptr& listener) const; private: - const EventQueue& getEventQueue(EventPriority priority) const; - - std::unique_ptr synchronousUnbatchedQueue_; - std::unique_ptr synchronousBatchedQueue_; - std::unique_ptr asynchronousUnbatchedQueue_; std::unique_ptr asynchronousBatchedQueue_; mutable EventListenerContainer eventListeners_; diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.cpp index bd9a7c0e39a21b..1b37492583777a 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.cpp @@ -58,14 +58,12 @@ EventEmitter::EventEmitter( void EventEmitter::dispatchEvent( std::string type, const folly::dynamic& payload, - EventPriority priority, RawEvent::Category category) const { dispatchEvent( std::move(type), [payload](jsi::Runtime& runtime) { return valueFromDynamic(runtime, payload); }, - priority, category); } @@ -80,19 +78,16 @@ void EventEmitter::dispatchUniqueEvent( void EventEmitter::dispatchEvent( std::string type, const ValueFactory& payloadFactory, - EventPriority priority, RawEvent::Category category) const { dispatchEvent( std::move(type), std::make_shared(payloadFactory), - priority, category); } void EventEmitter::dispatchEvent( std::string type, SharedEventPayload payload, - EventPriority priority, RawEvent::Category category) const { SystraceSection s("EventEmitter::dispatchEvent", "type", type); @@ -101,13 +96,11 @@ void EventEmitter::dispatchEvent( return; } - eventDispatcher->dispatchEvent( - RawEvent( - normalizeEventType(std::move(type)), - std::move(payload), - eventTarget_, - category), - priority); + eventDispatcher->dispatchEvent(RawEvent( + normalizeEventType(std::move(type)), + std::move(payload), + eventTarget_, + category)); } void EventEmitter::dispatchUniqueEvent( diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.h b/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.h index d31e30585ff101..04bb9ebe42c0d7 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/core/EventEmitter.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -66,19 +65,16 @@ class EventEmitter { std::string type, const ValueFactory& payloadFactory = EventEmitter::defaultPayloadFactory(), - EventPriority priority = EventPriority::AsynchronousBatched, RawEvent::Category category = RawEvent::Category::Unspecified) const; void dispatchEvent( std::string type, const folly::dynamic& payload, - EventPriority priority = EventPriority::AsynchronousBatched, RawEvent::Category category = RawEvent::Category::Unspecified) const; void dispatchEvent( std::string type, SharedEventPayload payload, - EventPriority priority = EventPriority::AsynchronousBatched, RawEvent::Category category = RawEvent::Category::Unspecified) const; void dispatchUniqueEvent(std::string type, const folly::dynamic& payload) diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventPriority.h b/packages/react-native/ReactCommon/react/renderer/core/EventPriority.h deleted file mode 100644 index bc1e9aa9b49ebc..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/core/EventPriority.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -namespace facebook::react { - -enum class EventPriority { - SynchronousUnbatched, - SynchronousBatched, - AsynchronousUnbatched, - AsynchronousBatched, - - Sync = SynchronousUnbatched, - Work = SynchronousBatched, - Interactive = AsynchronousUnbatched, - Deferred = AsynchronousBatched -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index 0e73b0a5cf3687..0e7fbdc2ca47ab 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -136,15 +136,13 @@ std::shared_ptr ShadowNodeFamily::getMostRecentStateIfObsolete( return mostRecentState_; } -void ShadowNodeFamily::dispatchRawState( - StateUpdate&& stateUpdate, - EventPriority priority) const { +void ShadowNodeFamily::dispatchRawState(StateUpdate&& stateUpdate) const { auto eventDispatcher = eventDispatcher_.lock(); if (!eventDispatcher) { return; } - eventDispatcher->dispatchStateUpdate(std::move(stateUpdate), priority); + eventDispatcher->dispatchStateUpdate(std::move(stateUpdate)); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h index dc5dbc815317f0..92f79cfb532e2b 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h @@ -96,8 +96,7 @@ class ShadowNodeFamily final { /* * Dispatches a state update with given priority. */ - void dispatchRawState(StateUpdate&& stateUpdate, EventPriority priority) - const; + void dispatchRawState(StateUpdate&& stateUpdate) const; /* * Holds currently applied native props. `nullptr` if setNativeProps API is