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

Cannot access a disposed object - iOS #330

Open RemcoDEV opened 3 years ago

RemcoDEV commented 3 years ago

Using version: Com.Airbnb.Xamarin.Forms.Lottie 4.0.9

Occurs on: iOS

Code: (wrapped in a control template) image

Stacktrace: An error occurred: 'Cannot access a disposed object. Object name: 'Airbnb.Lottie.LOTAnimationView'.'. Callstack: ' at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:34 at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:29 at UIKit.UIView.AddSubview (UIKit.UIView view) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:266 at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].SetNativeControl (TNativeView uiview) [0x00047] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:240 at Lottie.Forms.Platforms.Ios.AnimationViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x002ea] in C:\Users\mhvdi\Documents\OpenSource\LottieXamarin\Lottie.Forms\Platforms\Ios\AnimationViewRenderer.cs:118 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296 `

Seuleuzeuh commented 3 years ago

Same occured in my Android app caused by the AppThemeBinding :

Xamarin Exception Stack:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Lottie.Forms.Droid.AnimationViewRenderer'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42748fcc36b74733af2d9940a8f3cc8e>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42748fcc36b74733af2d9940a8f3cc8e>:0
  at Android.Views.View.SetBackgroundColor (Android.Graphics.Color color) [0x00028] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].UpdateBackgroundColor () [0x00016] in <04c545f414d24a37af95d995791bb9a9>:0
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00017] in <04c545f414d24a37af95d995791bb9a9>:0
  at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00000] in <04c545f414d24a37af95d995791bb9a9>:0
  at Lottie.Forms.Droid.AnimationViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x001eb] in <2b324cd31ffa4ee7ab1434653ff010ff>:0
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x0011b] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.AppThemeBinding.ApplyCore () [0x00028] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Xamarin.Forms.AppThemeBinding.<.ctor>b__2_1 () [0x00000] in <978ec34c5c9c4c4eb3d73b6da958bcd6>:0
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)`
KonstantinKellermann commented 3 years ago

Is there a work around for this issue? I am facing the same issue with version 4.0.10. But I'm not really sure this issue gets really triggered by this nuget, maybe xamarin or something else.

sofiaprice commented 3 years ago

I am having this issue on both iOS and Android on 4.0.10. It is triggered when I navigate to another tab with lotties from a tab with lotties, then back again.

MMieszko commented 2 years ago

I have the same. Lottie animation is an EmptyView template for CarouselView.

[0:] An error occurred: 'Cannot access a disposed object. Object name: 'Airbnb.Lottie.LOTAnimationView'.'. Callstack: ' at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:34 at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:29 at UIKit.UIView.AddSubview (UIKit.UIView view) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:240