opened
dominik-weber
username_0
When quickly adding/removing images the app crashes with a NullReference exception:

```
   at FFImageLoading.Forms.WinUWP.CachedImageRenderer.ImageLoadingFinished(CachedImage element)
   at FFImageLoading.Forms.WinUWP.CachedImageRenderer.<>c__DisplayClass9_0.<UpdateSource>b__0(IScheduledWork work)
   at FFImageLoading.Work.ImageLoaderTaskBase.<>c__DisplayClass51_3.<ConfigureParameters>b__5()
   at FFImageLoading.Helpers.MainThreadDispatcher.<>c__DisplayClass3_0.<Post>b__0()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at FFImageLoading.Helpers.MainThreadDispatcher.<Post>d__3.MoveNext()
```

The problem here might be that the view is already removed from the page once the image is loaded.
You can reproduce the issue with this code:

```
        public App()
        {
            var page = new ContentPage();

            MainPage = page;

            Device.StartTimer(TimeSpan.FromSeconds(0.1), () =>
            {
                page.Content = new FFImageLoading.Forms.CachedImage() { Source = "https://blog.optimizely.de/files/2014/01/test.jpg" };
                return true;
            });
        }
```

This code works fine on ios.
Xamarin Forms UWP app crashes when quickly adding/removing CachedImage views
issue
created
daniel-luberda
username_1
Thank you for the info & collaboration! I'll introduce some additional checks.
comment
closed
daniel-luberda
username_1
issue
created
dominik-weber
username_0
Did you already upload a new build so I can check if the issue is fixed?
Just fyi, I think the second null check could be removed. Casting an object should not return null.
comment
created
daniel-luberda
username_1
Yes, second null check can be removed, but it has so minimal impact that I'll do it someday (Please notice there's a reflection hack for InvalidateMeasure method which was mistakenly removed in some XF 2.x builds) - we'll need to remove it someday.
comment
created
dominik-weber
username_0
works fine, thank you man! also thanks to @CaLxCyMru for supplying the fix ;)
comment