jamesmontemagno / MediaPlugin

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

CrossMedia.Current.TakePhotoAsync crashes on Android Phone after taking and Saving Picture. It works well on Android Emulator... #952

Open aproko234 opened 1 year ago

aproko234 commented 1 year ago

ONLY Post issues against Latest Beta!!!

Make sure you follow all of the setup directions before posting an issue: https://github.com/jamesmontemagno/MediaPlugin#important-permission-information

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

Version Number of Plugin: 6.0.1- Beta Device Tested On: 21/11/2022 Simulator Tested On: 21/11/2022 Version of VS: 17.4.1 Version of Xamarin: 5.0.0.2515 Versions of other things you are using:

Steps to reproduce the Behavior

When I debug my solution in the android emulator, I can successfully take a picture with the CrossMedia.Current.TakePhotoAsync and it doesn't crash after taking the picture and tapping on the "good or accept" symbol to proceed.

But on my physical android device [Techno Spark 4 Air (Android 9)], after taking the picture, after I tap the "good or accept" symbol to proceed, the app appears to delay for some seconds and afterwards crashes.

No errors are displayed. I even put a DisplayAlert command just after the TakePhotoAsync, but it doesn't get there. I have put everything in a try...catch routine, but the apparent issue is not being trapped.

Expected Behavior

I expect after taking the picture and tapping on the "good or accept" symbol, the app should continue to execute the code after it and not just crash. My aim is to send the photo file so created and saved as an attachment via email.

Actual Behavior

After taking a picture and tapping on the "good or accept" symbol, the app appears to delay for a few seconds and then crashes on my android testing device. It works well on the Android Emulator.

Code snippet

                    await CrossMedia.Current.Initialize();

                    var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        PhotoSize = PhotoSize.Medium,                           
                        Directory = "AAPictures",
                        Name = $"{DateTime.UtcNow}.mp4"

                    });

                    if (file == null)
                        return;

Screenshots