Repository navigation
Conversation
|
@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129152896. |
Summary: **Problem**: With C++ Native Animated enabled on iOS, native-driven `Animated.event` mappings no longer receive events that libraries deliver through `RCTEventDispatcher` observers. The legacy ObjC Native Animated module observed them; C++ Native Animated only reads Fabric event payloads (event dispatched with `eventEmitter->dispatchEvent(name, folly::dynamic)`), and codegen'd component events are not readable from C++. As a result, in some of `react-navigation` (oss library) examples, Gesture- and pager-driven animations (swipe-back in a JS stack navigator, tab indicators driven by a pager's `onPageScroll`) stop tracking user input. **Proposed change**: When C++ Native Animated is enabled, `RCTInstance` observes its `RCTEventDispatcher` and hands each component event, on the main thread, to an `EventEmitterListenerContainer` it publishes in the context container under `RCTEventDispatcherListeners`. On Apple platforms, `NativeAnimatedNodesManagerProvider::getOrCreate()` adds its event listener to that container when present, next to its Fabric event listener. An **alternative** is to let the library migrate to `EventEmitter::dispatchEvent`; however that way the event is also delivered to JS. In android and RNCXX, we also maintain 2 paths to intercept js dispatchEvent and platform-only event. **Changes**: - iOS (`RCTInstance`, new `RCTEventDispatcherEventPayload`): registers as an `RCTEventDispatcherObserver` only when `cxxNativeAnimatedEnabled()` is on, and forwards only component events (`RCTEventEmitter.receiveEvent`). The payload reads values from the event body on demand, so events no listener reads are not converted; it is never dispatched to JS. - C++ (`NativeAnimatedNodesManagerProvider`, `__APPLE__` only): subscribes to `RCTEventDispatcherListeners` from the UIManager's context container. Covers the platform-driven and shared animation backend setups, and apps that create their own provider. - C++: `EventEmitterListener.h` moves from `react/renderer/animated` to `react/renderer/core` (the runtime only needs `core`); `react/renderer/animated/EventEmitterListener.h` forwards to it for existing includers. No public API changes. Found while auditing `cxxNativeAnimatedEnabled` against OSS react-navigation (7.x) and its peers react-native-gesture-handler, react-native-pager-view and react-native-screens. Changelog: [iOS][Fixed] - Native-driven `Animated.event` mappings receive events delivered through `RCTEventDispatcher` observers when C++ Native Animated is enabled Differential Revision: D129152896
zeyap
force-pushed
the
export-D129152896
branch
from
November 2, 2026 22:55
7bc5cda to
607205e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Problem: With C++ Native Animated enabled on iOS, native-driven
Animated.eventmappings no longer receive events that libraries deliver throughRCTEventDispatcherobservers. The legacy ObjC Native Animated module observed them; C++ Native Animated only reads Fabric event payloads (event dispatched witheventEmitter->dispatchEvent(name, folly::dynamic)), and codegen'd component events are not readable from C++.As a result, in some of
react-navigation(oss library) examples, Gesture- and pager-driven animations (swipe-back in a JS stack navigator, tab indicators driven by a pager'sonPageScroll) stop tracking user input.Proposed change: When C++ Native Animated is enabled,
RCTInstanceobserves itsRCTEventDispatcherand hands each component event, on the main thread, to anEventEmitterListenerContainerit publishes in the context container underRCTEventDispatcherListeners. On Apple platforms,NativeAnimatedNodesManagerProvider::getOrCreate()adds its event listener to that container when present, next to its Fabric event listener.An alternative is to let the library migrate to
EventEmitter::dispatchEvent; however that way the event is also delivered to JS. In android and RNCXX, we also maintain 2 paths to intercept js dispatchEvent and platform-only event.Changes:
RCTInstance, newRCTEventDispatcherEventPayload): registers as anRCTEventDispatcherObserveronly whencxxNativeAnimatedEnabled()is on, and forwards only component events (RCTEventEmitter.receiveEvent). The payload reads values from the event body on demand, so events no listener reads are not converted; it is never dispatched to JS.NativeAnimatedNodesManagerProvider,__APPLE__only): subscribes toRCTEventDispatcherListenersfrom the UIManager's context container. Covers the platform-driven and shared animation backend setups, and apps that create their own provider.EventEmitterListener.hmoves fromreact/renderer/animatedtoreact/renderer/core(the runtime only needscore);react/renderer/animated/EventEmitterListener.hforwards to it for existing includers.No public API changes.
Found while auditing
cxxNativeAnimatedEnabledagainst OSS react-navigation (7.x) and its peers react-native-gesture-handler, react-native-pager-view and react-native-screens.Changelog:
[iOS][Fixed] - Native-driven
Animated.eventmappings receive events delivered throughRCTEventDispatcherobservers when C++ Native Animated is enabledDifferential Revision: D129152896