Commit 9efffe1
authored
Update AnimatedColor-test.js
## Summary:
Fixed an issue in AnimatedColor.js where _listenerCount could become negative during complex unmount phases. When __detach() is executed, it invokes removeAllListeners() on underlying channel nodes (r, g, b, a), resetting counts to 0. Subsequent stale infrastructure cleanups invoke removeListener(), which blindly decrements the counter to -1, bypassing the === 0 check and leaking native subscriptions permanently.
## Changelog:
[General] [Fixed] - Prevent negative listener count and native subscription memory leaks in AnimatedColor during detach cascades
## Test Plan:
Added a comprehensive regression test suite in packages/react-native/Libraries/Animated/tests/AnimatedColor-test.js covering:
- Verifying _listenerCount does not drop into negative values after a __detach() and subsequent removeListener() execution.
- Testing removeListener safely acts as a no-op when called after removeAllListeners().
- Ensuring native driver subscriptions are properly initiated and systematically torn down without memory leaks.
Tested locally by running:
yarn jest AnimatedColor-test1 parent 34e35b2 commit 9efffe1
0 file changed
0 commit comments