mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52081 changelog: [internal] # The problem in Java and Obj-C Native Animated -------------------- Event based animations in Native Animated have one big problem: detecting when the gesture is completed. This has led to number of bugs over the years that manifest as Pressable's onPress not triggering. The root cause of the problem is disconnect between where a piece of UI is on the screen and where Fabric thinks it is. Fabric is used for hit testing, and other things like intersection observing, and if Fabric does not have up to date values, weird things start happening. This diff implements completion detection for event based animations. Unlike previous solutions, it does not depend on sequence of events nor it uses React setState to update shadow tree. # Completion Detection -------------------- The key mechanism for marking event animations as completed is in the `onRender` method: - After processing animations, if `onAnimationFrame` returns false - indicating no UI changes, the system assumes all event-driven animations have completed. - it then: * Collects all animated value nodes connected to event drivers. * Updates all nodes connected to these "finished" animations. * isEventAnimationInProgress_ to false. * Commits final property values to the UI. The benefits over the previous solution: - It works across all platforms without the need to emit "completion events". - It uses a UI frame that wouldn't animate anything to do syncing work. Using main thread IDLE time towards bookkeeping. - No need to call into JavaScript for synchronisation. Reviewed By: zeyap Differential Revision: D76743467 fbshipit-source-id: b21ab5ef9c71ff93fd0250e6af6b22ded395be8d