Baseflow / LottieXamarin

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin

Home Page:https://baseflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get Null Reference Exception

yonkahlon opened this issue Β· comments

πŸ› Bug Report

We're seeing a null reference exception for some of our users. I've really struggled to reproduce it, but I think it happens when we redo the UI layout. The UI has a few states, where a user can minimize or maximize a book reader. In that transition we remove multiple views from the grid, redefine the grid and then add the views into the correct place.

I've switched 100s of times and can't recreate the issue, but was after doing that when I saw the exception come up.

Here is the stack trace:

AnimationViewRenderer+<>c__DisplayClass4_0.b__0 ()
<.ctor>b__0 (System.Object o)
Command.Execute (System.Object parameter)
LottieExtensions.ExecuteCommandIfPossible (System.Windows.Input.ICommand command, System.Object parameter)
AnimationView.PlayAnimation ()
BookReaderControl.UpdateTap (Monkey.Kids.Types.RTCDataChannelTypes.BookTapEventArgs tap, Lottie.Forms.AnimationView animation)
BookReaderControl.UpdateRemoteTap ()
BookReaderControl.OnRemoteTap (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue)
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)
RoomPage.LoadPortraitLayoutVideoMaximized ()

In the RoomPage.LoadPortraitLayoutVideoMaximized() function we start to add all the views into the correct location.

If I understand correctly AnimationView.PlayAnimation() will call this code in the AnimationViewRenderer:

e.NewElement.PlayCommand = new Command(() =>
{
    _animationView.PlayWithCompletion(AnimationCompletionBlock);
    e.NewElement.InvokePlayAnimation();
});

Only 2 things can be null here (I think?). That is _animationView or AnimationCompletionBlock. If e or e.NewElement was null then you couldn't execute the command?

Configuration

My project is a Xamarin.Forms project, and I saw the crash on an iPhone XR

Version: 4.09

Platform:

  • πŸ“± iOS
  • πŸ€– Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • πŸ“Ί tvOS
  • πŸ’ Xamarin.Forms

The same issue with me for version 4.0.9 with Xamarin.Forms for iOS platform.
Also some times handling
AnimationViewRenderer+<>c__DisplayClass4_0.b__3 ()