Baseflow / Baseflow/LottieXamarin

Get Null Reference Exception

Open
#335 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
253
PR merge metrics
No merged PRs in 30d

Description

## 🐛 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:**
- [x] :iphone: iOS
- [ ] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [x] :monkey: Xamarin.Forms

Contributor guide

Open the contributing guide

Research direction

Start by tracing the stack from AnimationViewRenderer and AnimationView.PlayAnimation through BookReaderControl.UpdateTap to RoomPage.LoadPortraitLayoutVideoMaximized. Check the Xamarin.Forms iOS layout transition and the mentioned animation objects while reviewing the available tests. Done means the null-reference path is identified and covered by a regression test or a confirmed fix.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.