ArgumentNullException on iOS for animation using ImageAssetsFolder
See original GitHub issue🐛 Bug Report
After updating from v3.1.3 to v4.0.4 I get an exception in animation using ImageAssetsFolder
on iOS. The animation worked fine in v3.1.3.
The animation plays fine in the Android version of my app on v4.0.4 (I am using the Xamarin.Forms component).
The exception I get is:
System.ArgumentNullException: Value cannot be null.
Parameter name: bundle
at Airbnb.Lottie.LOTComposition.AnimationNamed (System.String animationName, Foundation.NSBundle bundle) [0x00011] in /Users/martijn/Documents/OpenSource/LottieXamarin/Lottie.iOS/obj/Release/xamarin.ios10/ios/Airbnb.Lottie/LOTComposition.g.cs:137
at Lottie.Forms.Platforms.Ios.AnimationViewExtensions.GetAnimation (Lottie.Forms.AnimationView animationView) [0x00059] in C:\Users\mhvdi\Documents\OpenSource\LottieXamarin\Lottie.Forms\Platforms\Ios\AnimationViewExtensions.cs:24
at Lottie.Forms.Platforms.Ios.AnimationViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x000f6] in C:\Users\mhvdi\Documents\OpenSource\LottieXamarin\Lottie.Forms\Platforms\Ios\AnimationViewRenderer.cs:50
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:227
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:115
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:49
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:227
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:115
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:49
at Xamarin.Forms.Platform.iOS.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00087] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ScrollViewRenderer.cs:71
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:227
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:115
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:49
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:237
at 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/14.0.0.0/src/Xamarin.iOS/UIKit/UIViewController.g.cs:3267
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:103
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:119
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:227
at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:339
at Xamarin.Forms.Platform.iOS.Platform.WillAppear () [0x0003c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:325
at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (System.Boolean animated) [0x00018] in D:\a\1\s\Xamarin.Forms.Platform.iOS\PlatformRenderer.cs:95
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at Blueye.App.iOS.Application.Main (System.String[] args) [0x00001] in /Users/follesoe/source/BlueyeApp/iOS/Main.cs:12
Looking at the source code, the relevant lines are: https://github.com/Baseflow/LottieXamarin/blob/develop/Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs#L24
Expected behavior
The animation should play on iOS the same way it does on Android, and in version 3.1.3 on iOS.
Reproduction steps
If needed I can provide the specific animation later. My XAML element looks like this:
<lottie:AnimationView
x:Name="animationView"
BackgroundColor="Transparent"
Animation="{Binding Animation}"
RepeatMode="Infinite"
AutoPlay="true"
VerticalOptions="Center"
HorizontalOptions="Fill"
Margin="40"
WidthRequest="240"
HeightRequest="220"/>
The ImageAssetFolder
property is set like this: animationView.ImageAssetsFolder = "LottieAnimations/Images";
.
On iOS, the images are added to the asset catalog. Could this perhaps be the source of the issue?
Configuration
Version: 4.04
Platform:
- 📱 iOS
- 🤖 Android
- 🏁 WPF
- 🌎 UWP
- 🍎 MacOS
- 📺 tvOS
- 🐒 Xamarin.Forms
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I’ve added some checks, so maybe this works a bit better now. Can you test?
I think we can conclude that the
ImageAssetsFolder
was ignored in the 3.0 release. Tested setting the property on iOS and I do not get a runtime exception in version 4.0.6.