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

Animations in recycled components seem to be broken from v3.9.0 and up #6203

Closed
LcTwisk opened this issue Jul 3, 2024 · 9 comments · Fixed by #6218
Closed

Animations in recycled components seem to be broken from v3.9.0 and up #6203

LcTwisk opened this issue Jul 3, 2024 · 9 comments · Fixed by #6218
Assignees
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS

Comments

@LcTwisk
Copy link

LcTwisk commented Jul 3, 2024

Description

The changes in #5268 result in animations not properly resetting when a component is being recycled in e.g. a FlashList (even if the SharedValue's backing the animation are reset.

Was able to work around it by explicitly setting a property that would change when recycling. That results in the _requiresNewInitialshere to become true (because of a change in props). However, I'm not sure if this is the intended solution for recycling. Any thoughts?

      <Animated.View
+       key={index}
        style={animatedStyle}
        height={height}
        onLayout={onLayout}
      />

A video showing the issue in our app:

The following can be observed: an animation is triggered on component 1, but the state is not being reset when the component is recycled on index 11 (there's a recycle pool of 10 components).
The backing SharedValue's are being reset when the component is recycled:

if (id !== previousId.current) {
  stepperOpacity.value = 0;
  stepperTranslateX.value = 0;
  previousId.current = id;
}
RPReplay_Final1719850658.MP4

Steps to reproduce

  1. Create a large list with uniform components that will be recycled using e.g. a FlashList
  2. Animate a state change in the first item of the list
  3. Scroll down and see the animated style change appear on the recycled component (while the actual state change is reset)

Snack or a link to a repository

Will create a reproduction project later

Reanimated version

3.9.0 (and up)

React Native version

0.72.14

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Jul 3, 2024
Copy link

github-actions bot commented Jul 3, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label Jul 3, 2024
@erquhart
Copy link

erquhart commented Jul 4, 2024

I'm also seeing this - specifically, onScroll from a handler created with useAnimatedScrollHandler is no longer called on scroll in a FlashList animated via reanimated createAnimatedComponent. Happy to try early releases to test any fix candidates if it's helpful. Building with Expo for iOS.

@LeslieOA
Copy link

LeslieOA commented Jul 4, 2024

I've had to stick to 3.6.2 to not break my animations with FlashList (it's especially noticeable when mid-scroll and updating objects in an array).

@szydlovsky
Copy link
Contributor

Hey @erquhart @LeslieOA @LcTwisk could please try out the following patch?
reanimated_3.13.0_styles.patch

@LeslieOA
Copy link

LeslieOA commented Jul 5, 2024

Hey @erquhart @LeslieOA @LcTwisk could please try out the following patch? reanimated_3.13.0_styles.patch

I’m using Expo prebuild, but will see if I can create a confit plugin (or use build properties [???]) to apply the patch.
If not: I’ll branch and manually patch then get back to you later today. 🙏🏾

@LcTwisk
Copy link
Author

LcTwisk commented Jul 5, 2024

Hey @erquhart @LeslieOA @LcTwisk could please try out the following patch? reanimated_3.13.0_styles.patch

That's essentially reverting #5268, right? Yes, we're using a similar patch at the moment, and it fixed the issues we experienced 👍

@szydlovsky szydlovsky linked a pull request Jul 8, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Jul 9, 2024
## Summary

Unfortunately, turns out the PR with dynamic styles #5268 introduced
more problems than it solved. Thus, proposing a revert.
This revert most likely fixed:
-
#6203
-
#6102
-
#6037

as well as one more not-published issue and potentially a few more.

## Notes

Even if it gets approved, to be merged ONLY after @tjzel agrees with
everything

## Test plan

😢 😭
@szydlovsky
Copy link
Contributor

The fix should be there by the next stable version (3.14.0 or next iteration of 3.13.x)

@JustJoostNL
Copy link

@LcTwisk do you mind giving a small explaination on how you've used FlashList with react-native-reanimated. I can't get the layout transitions to work.

@erquhart
Copy link

erquhart commented Aug 4, 2024

@szydlovsky sorry it took so long to try this out - still broken for me as of 3.10.1.

Edit: apparently I can't read, you said 3.13x+. I'll try the actual patch.

Update: installed 3.14.0, works! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants