Baseflow / LottieXamarin

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

Cannot access a disposed object Com.Airbnb.Lottie.LottieAnimationView #365

Open Cvijo opened 2 years ago

Cvijo commented 2 years ago

🐛 Bug Report

I am using Lottie inside a custom control. In code-behind I set PlayAnimation() and StopAnimation() depending on IsBusy bindable property. When I navigate to another page and return back and when setting IsBusy = True, PlayAnimation() throw exception Cannot access a disposed object Com.Airbnb.Lottie.LottieAnimationView

I even tried to create LottieAnimationView from code-behind and attach it to StackLayout but it is the same error. when I inspect LottieAnimationView it is still there in memory, but PlayAnimation throws an exception.

Version: 4.0.11

will-spaulding commented 2 years ago

i had a similar issue with a databound list whos item template contains a lottie file. are you updating the IsBusy prop from the view model? if you are try using Device.BeginInvokeOnMainThread method. i can not say for sure that was my issue but its been several weeks with no crashes.

Device.BeginInvokeOnMainThread(() => { }