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

Reset animatedView when detaching AnimatedProps #46205

Closed
wants to merge 1 commit into from

Conversation

javache
Copy link
Member

@javache javache commented Aug 25, 2024

Summary:
When React.Activity unmounts and remounts effects, we fail to re-attach the native view to the NativeAnimated nodes, which causes animations to stop working.

Changelog: [Internal]

Reviewed By: bvanderhoof

Differential Revision: D61662164

Summary:
When React.Activity unmounts and remounts effects, we fail to re-attach the native view to the NativeAnimated nodes, which causes animations to stop working.

Changelog: [Internal]

Reviewed By: bvanderhoof

Differential Revision: D61662164
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Aug 25, 2024
@facebook-github-bot
Copy link
Contributor

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

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @javache in fdb77ae

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

@react-native-bot react-native-bot added the Merged This PR has been merged. label Aug 26, 2024
@javache javache deleted the export-D61662164 branch August 30, 2024 11:24
rhagigi pushed a commit to rhagigi/react-native that referenced this pull request Sep 11, 2024
…itch

Summary:
When hiding a view with React.Activity, React will "detach" all the views in teh subtree (call all their effect cleanups) and then upon showing it again will attach them (call all their effects again).

This was previously causing problems with useAnimatedProps and facebook#46205 was intended to fix it (cc javache), but it's still a perf drain to have to detach all of this and then re-attach it upon show. Worse, it makes it so that we can't actually do any animations upon re-showing a view until all the passive effects have run to re-attach the views to the animations.

So instead, what this diff does is lean on the fact that useInsertionEffect *does not* clean up and rerun when Activity goes from hidden to visible and vice versa. Thus, we can rely on it to only detach the animated node when we're *actually* unmounting - rather than when we're simply hiding/showing.

Reviewed By: yungsters, sammy-SC

Differential Revision: D62398039
facebook-github-bot pushed a commit that referenced this pull request Sep 11, 2024
…itch (#46438)

Summary:
Pull Request resolved: #46438

When hiding a view with React.Activity, React will "detach" all the views in teh subtree (call all their effect cleanups) and then upon showing it again will attach them (call all their effects again).

This was previously causing problems with useAnimatedProps and #46205 was intended to fix it (cc javache), but it's still a perf drain to have to detach all of this and then re-attach it upon show. Worse, it makes it so that we can't actually do any animations upon re-showing a view until all the passive effects have run to re-attach the views to the animations.

So instead, what this diff does is lean on the fact that useInsertionEffect *does not* clean up and rerun when Activity goes from hidden to visible and vice versa. Thus, we can rely on it to only detach the animated node when we're *actually* unmounting - rather than when we're simply hiding/showing.

Changelog:
[General][Changed] - Improved the performance of unmounting (and updating, when an enclosing Activity becomes hidden) Animated components

Reviewed By: yungsters, sammy-SC

Differential Revision: D62398039

fbshipit-source-id: af286e428188b5104f6cfd3fd4d8c9f791dedb8d
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