software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.09k stars 1.32k forks source link

[Fabric LA] Fix `maybeDropAncestors` condition. #6663

Open bartlomiejbloniarz opened 2 weeks ago

bartlomiejbloniarz commented 2 weeks ago

Summary

In the maybeDropAncestors function we can remove the view if it has no remaining animating views. Let's say we have nested exiting animations:

 flowchart TD
     A((A: EXITING))
     B((B: EXITING))
     C((C: WAITING))
     D((D: WAITING))
     E((E: WAITING))

     A --> B
     A --> C
     A --> D
     A --> E

In the current implementation in this case if the animation in B ended before A, we would visit A in maybeDropAncestors and decided to remove A, even though it still has some waiting children. Then A would be added to the view recycling pool while still having children. This would cause us to see some zombie views when the view is reused.

I changed the maybeDropAncestors condition to check the size of the children list. I also removed node->animatedChildren as I think it is no longer necessary.

Fixes #6644

Test plan

Chceck [LA] View recycling example, if there are no zombie views in the WheelPicker component.