Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated: Fix onUserDrivenAnimationEnded w/ Insertion Effects #48678

Closed
wants to merge 1 commit into from

Conversation

yungsters
Copy link
Contributor

Summary:
While diagnosing a recent issue in which AnimatedValue instances were not being correctly updated as expected, the insertion effects feature flag was identified as a root cause.

Upon further investigation, it appears that this is because the onUserDrivenAnimationEnded listener was not implemented the same way in the two feature flag states:

  • When useInsertionEffectsForAnimations is disabled, useAnimatedProps listens to onUserDrivenAnimationEnded in a passive effect, after all nodes have been attached.
  • When useInsertionEffectsForAnimations is enabled, useAnimatedProps listens to onUserDrivenAnimationEnded in an insertion effect when attaching nodes.

The bugs occurs because useAnimatedProps checks whether native driver is employed to decide whether to listen to onUserDrivenAnimationEnded. However, we do not know whether native driver will be employed during the insertion effect. (Actually, we do not necessarily know that in a passive effect, either... but that is a separate matter.)

This fixes the bug when that occurs when useInsertionEffectsForAnimations is enabled, by moving the listening logic of onUserDrivenAnimationEnded into a passive effect. This is the same way that it is implemented when useInsertionEffectsForAnimations is disabled.

Changelog:
[Internal]

Differential Revision: D68171721

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 14, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68171721

…book#48678)

Summary:

While diagnosing a recent issue in which `AnimatedValue` instances were not being correctly updated as expected, the insertion effects feature flag was identified as a root cause.

Upon further investigation, it appears that this is because the `onUserDrivenAnimationEnded` listener was not implemented the same way in the two feature flag states:

- When `useInsertionEffectsForAnimations` is disabled, `useAnimatedProps` listens to `onUserDrivenAnimationEnded` in a passive effect, after all nodes have been attached.
- When `useInsertionEffectsForAnimations` is enabled, `useAnimatedProps` listens to `onUserDrivenAnimationEnded` in an insertion effect when attaching nodes.

The bugs occurs because `useAnimatedProps` checks whether native driver is employed to decide whether to listen to `onUserDrivenAnimationEnded`. However, we do not know whether native driver will be employed during the insertion effect. (Actually, we do not necessarily know that in a passive effect, either... but that is a separate matter.)

This fixes the bug when that occurs when `useInsertionEffectsForAnimations` is enabled, by moving the listening logic of `onUserDrivenAnimationEnded` into a passive effect. This is the same way that it is implemented when `useInsertionEffectsForAnimations` is disabled.

Changelog:
[Internal]

Differential Revision: D68171721
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68171721

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 15, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 00d272f.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @yungsters in 00d272f

When will my fix make it into a release? | How to file a pick request?

yungsters added a commit to yungsters/react-native that referenced this pull request Jan 15, 2025
Summary:
{D68171721} [facebook#48678](facebook#48678) mitigated the bug that necessitated this revert.

Changelog:
[General][Changed] - (Reapply) The `AnimatedNode` graph will not occur during the insertion effect phase, which means animations can now be reliably started during layout effects.

Differential Revision: D68217144
facebook-github-bot pushed a commit that referenced this pull request Jan 15, 2025
Summary:
Pull Request resolved: #48708

{D68171721} [#48678](#48678) mitigated the bug that necessitated this revert.

Changelog:
[General][Changed] - (Reapply) The `AnimatedNode` graph will not occur during the insertion effect phase, which means animations can now be reliably started during layout effects.

Reviewed By: sammy-SC

Differential Revision: D68217144

fbshipit-source-id: 6796440f2839d897158528642e07869951651327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants