Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin forms iOS Cannot access a disposed object #394

Open
2 tasks
jeroduck opened this issue Aug 10, 2023 · 1 comment
Open
2 tasks

Xamarin forms iOS Cannot access a disposed object #394

jeroduck opened this issue Aug 10, 2023 · 1 comment

Comments

@jeroduck
Copy link

🐛 Bug Report

On Xamarin Forms, everything works on Android, but on iOS, I received on execution:

An error occurred: 'Cannot access a disposed object

Object name: 'Airbnb.Lottie.LOTAnimationView'.'. Callstack: ' at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/ObjCRuntime/ThrowHelper.cs:52
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/ObjCRuntime/INativeObject.cs:35
at UIKit.UIView.AddSubview (UIKit.UIView view) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/UIKit/UIView.g.cs:240
at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].SetNativeControl (TNativeView uiview) [0x00047] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:244 at Lottie.Forms.Platforms.Ios.AnimationViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x002ea] in Z:\Documents\OpenSource\LottieXamarin\Lottie.Forms\Platforms\Ios\AnimationViewRenderer.cs:117
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:252
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2938
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:104
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:120
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:378
at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:353
at Xamarin.Forms.NavigationPage.PushAsyncInner (Xamarin.Forms.Page page, System.Boolean animated) [0x00084] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:452
at Xamarin.Forms.NavigationPage.PushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x0014e] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:265
at infraspadmobile.DisclaimerFull.TapGestureConfirmed_Tapped (System.Object sender, System.EventArgs e) [0x0005e] in C:\src\GIT\a1680-spad\infraspad-mobile\infraspadmobile\DisclaimerFull.xaml.cs:42
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at (wrapper delegate-invoke) .invoke_void_object(object)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/Foundation/NSAction.cs:176
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/UIKit/UIApplication.cs:58
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.5/src/Xamarin.iOS/UIKit/UIApplication.cs:84
at infraspadmobile.iOS.Application.Main (System.String[] args) [0x00007] in C:\src\GIT\a1680-spad\infraspad-mobile\infraspadmobile.iOS\Main.cs:21
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '

Expected behavior

an animation :)

Reproduction steps

<lottie:AnimationView AnimationSource="EmbeddedResource"
Grid.Row="1" IsVisible="false"
x:Name="lotLoading"
Animation="Lottie.78259-loading.json"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
RepeatMode="Infinite"/>

The file is in the folder Lottie and it is defined as Embedded Resource

Configuration

Version: 4.1.0

Platform:

  • 📱 iOS 16 failed
  • :android: Android 13 worked
@jeroduck jeroduck changed the title Xamarin forms IOS Cannot access a disposed object Xamarin forms iOS Cannot access a disposed object Aug 10, 2023
@nk-alex
Copy link

nk-alex commented Oct 3, 2023

Hard to tell with provided information.

Have you installed Com.Airbnb.iOS.Lottie on your iOS project?

Also, animation file should have "BundleResource" Build Action for iOS.

If nothing works, I suggest you clone samples folder and try running them in your environemnt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants