Baseflow / Baseflow/LottieXamarin
Cannot access a disposed object - iOS
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 253
- PR merge metrics
- No merged PRs in 30d
Description
Using version: Com.Airbnb.Xamarin.Forms.Lottie 4.0.9
Occurs on:
iOS
Code: (wrapped in a control template)

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.ViewRenderer`2[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.ElementChangedEventArgs`1[TElement] e) [0x002ea] in C:\Users\mhvdi\Documents\OpenSource\LottieXamarin\Lottie.Forms\Platforms\Ios\AnimationViewRenderer.cs:118
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296
`
Contributor guide
Research direction
The iOS path is Lottie.Forms/Platforms/Ios/AnimationViewRenderer.cs, with failure at OnElementChanged line 118 while Xamarin.Forms ViewRenderer.SetNativeControl calls UIView.AddSubview. Reproduce the supplied control-template case on Com.Airbnb.Xamarin.Forms.Lottie 4.0.9, then trace when LOTAnimationView is disposed; done means the case no longer raises Cannot access a disposed object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100