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

fix: Break circular reference in `AndroidUIScheduler` #6670

Closed lukmccall closed 1 week ago

lukmccall commented 2 weeks ago

Summary

Breaks circular reference in the AndroidUIScheduler.

AndroidUIScheduler is a HybridClass that has a C++ counterpart holding a global reference to the Java object. This structure creates a circular reference between C++ and Java, which the garbage collector cannot clean up. To resolve this issue, I manually remove the reference between Java and C++ by calling resetNative when the scheduler is deactivated.

Test plan

lukmccall commented 1 week ago

Closes in favour of https://github.com/software-mansion/react-native-reanimated/pull/6697.