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/46714 Sets up a feature flag to experiment with scheduling `Animation` completion callbacks in a microtask instead of executing them synchronously. (The completion callback is the callback passed into `animation.start(<callback>)`). There are currently 4 potential scheduling behaviors of the animation completion callback: - Synchronously when `start()` is invoked, for spring and timing animations that immediately complete (e.g. no delays and not native driver). - Synchronously when `stop()` is invoked, if the animation has not yet completed. - Synchronously during the layout effect phase, or commit phase (if the `useInsertionEffectsForAnimations` feature flag is enabled), if the animation has not yet completed. - Asynchronously when the animation completes (e.g. non-zero delay or when the native driver is employed). The wide number of variables and the timing-dependent nature of these variables means that the behavior of the completion callback is very non-deterministic. Imperically, we have also found that most codebases using `useNativeDriver` mostly have completion callbacks executed asynchronously. However, this leads to surprising problems where the callback causes unpredictable behavior when it is called synchronously (e.g. when the animating component is unmounted *during* the animation). Changelog: [Internal] Reviewed By: javache Differential Revision: D63573322 fbshipit-source-id: 16c48be78c9ac65a64021249fad10f7265737c44