question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
martijn00commented, Oct 27, 2020

I’ve added some checks, so maybe this works a bit better now. Can you test?

0reactions
follesoecommented, Nov 5, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArgumentNullException: Value cannot be null. on iOS device
It says on iOS to get them by "Access the device log in XCode via the GDB console or the Organizer Console". But...
Read more >
SwiftUI: 'value' parameter not working as expected in iOS ...
I'm trying to solve the iOS 15's warning: 'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead. in a ...
Read more >
I wanna learn to animate on my iPad, where do i start? and ...
I wanna learn to animate on my iPad, where do i start? and any important tips/info before i start on my journey? :...
Read more >
2D Keyframe Animation on iPad - Callipeg - YouTube
Share your animations on Instagram with @callipeg.app or #callipeg, ... on iPad | How to animate using transformation layers in Callipeg.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found