MemoryLeak in LottieDrawable
See original GitHub issueIn LottieDrawable consturction method, it will auto add a annoyous update listener and refer the drawable and context, cause the activity leak. How to remove the update listener to avoid memory leak?
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
if (compositionLayer != null) {
compositionLayer.setProgress(animator.getValue());
}
}
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Memory leak in lottie-web - Stack Overflow
I'm using lottie web on my front-end. But I still having problem with memory leak. When I remove all lottie, JavaScript VM instance...
Read more >5.0.1
Dedicated memory for Lottie was always allocated. ... However, custom uses of LottieDrawable were prone to leaking infinite animators if they did not ......
Read more >Lottie Android 5.0 - Gabriel Peal
Reduced memory consumption: In the hardware case, no new memory is allocated. · RenderMode: Lottie Compose and LottieDrawable now support setting a RenderMode....
Read more >Lottie Android Versions - Open Source Agenda
... Use the application context in NetworkFetcher to prevent memory leaks (#1832) ... Added support for pause listeners on LottieDrawable and ...
Read more >Java – How to set loop number of lottiefiles animation in android ...
setRepeatCount(LottieDrawable.INFINITE);// for Infinite loops ... Java – How to convert a String to an int in Java · Java – How to create...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Newer versions of Lottie will unschedule the drawable when it is detached from the window.
It is dumped from online data and not easy to produce. I read ValueAnimator source and have some suspects. When animator is scheduled, AnimationHandler singleton will hold the reference to ValueAnimator. Until animator is canceled or stopped, AnimationHandler will remove the reference. So it might have a case:
To avoid this case, we manually call LottieAnimationView#cacelAnimation() in activity#onDestory() lifecycle callback. It release the reference from AnimationHandler to ValueAnimation.