jamesmontemagno / MediaPlugin

Take & Pick Photos and Video Plugin for Xamarin and Windows
MIT License
711 stars 360 forks source link

Crashing if you didn't pick photo on Pixel 5 simulator with null reference exception #938

Closed MhAllan closed 2 years ago

MhAllan commented 3 years ago

If you didn't pick any photo and clicked the back button on Pixel 5 simulator it will crash with null reference exception and the exception is not catchable even which is weird

 public async Task<MediaFile> PickPhoto()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    throw new Exception(":not supported");
                }

                return await CrossMedia.Current.PickPhotoAsync();
            }
            catch(Exception ex) // this is not reachable
            {
                return null;
            }
            finally
            {
                Toast("Done"); // this is also not reachable
            }
        }

image

jamesmontemagno commented 2 years ago

Unable to reproduce issue with latest beta packages.