Baseflow / LottieXamarin

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin
https://baseflow.com
Apache License 2.0
1.22k stars 261 forks source link

LOTAnimationView causes performance issues when used in UICollectionView's BackgroundView #248

Closed adrianknight89 closed 4 years ago

adrianknight89 commented 4 years ago

šŸ› Bug Report

I don't have a reproduction project right now, but I'm having trouble using Lottie in Xamarin.iOS. I added an animation to the BackgroundView of a UICollectionView when the collection is empty (e.g. no result found view). When the collection receives items, then I pause and dispose the animation, remove it from its superview, and null out the BackgroundView. The problem is scrolling becomes jittery when I scroll up and down. This only happens if I have called Play() on the animation. To me, it looks like there is a memory leak somewhere.

var lotAnimationView = LOTAnimationView.AnimationNamed("animation");
lotAnimationView.LoopAnimation = true;
lotAnimationView.TranslatesAutoresizingMaskIntoConstraints = false;

uiStackView.AddArrangedSubview(lotAnimationView);

lotAnimationView.WidthAnchor.ConstraintEqualTo(150).Active = true;
lotAnimationView.HeightAnchor.ConstraintEqualTo(150).Active = true;

lotAnimationView.Play(); // causes jittery scrolling when `BackgroundView` is disposed

Expected behavior

LOTAnimationView needs to be disposed properly so that UICollectionView performance is not affected negatively.

Platform: