xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 505 forks source link

[Bug] repeated use of MediaPicker.CapturePhotoAsync restarts my app on Android 11 #1882

Open nebeskm opened 3 years ago

nebeskm commented 3 years ago

Description

I need to take more photos, but the app restarts on Android 11 devices. Android 10 or lower is OK. It behaves enigmatic. Sometimes it happens after third capturing, sometimes maybe after seventh capturing.

Simulation of the problem (restart after second capturing):

  1. Click Button for take a picture
  2. Take a picture
  3. Click OK
  4. App returns to the screen with button
  5. Steps 1-3
  6. App restarts and displays the home screen

If I place a breakpoint on var photo = await MediaPicker.CapturePhotoAsync(); and go to next step, nothing gets done and app crashes.

Basic Information

nebeskm commented 3 years ago

This also happens in App-Essentials Sample App

Brunoporto2702 commented 3 years ago

Hi! I have been also having this trouble!

Did find any solution on that?

Cheers!

lukaszfuturum commented 2 years ago

Any news on this topic ?

SilvioLuizGuimaraes commented 2 years ago

Still no solution?

nebeskm commented 2 years ago

It's probably a bug in Android 11. No problem after update my Galaxy Tab S6 to Android 12.

Jerome-Liger commented 2 years ago

Same problem in production... 10 month later and no solution/workaround ?

wx0322 commented 2 years ago

这个问题有解决方案了吗?

MitchBomcanhao commented 2 years ago

We had similar issues when using the media plugin (which will be very similar to the code in essentials). This seems to be memory related.

on our application I could see this happening easily on devices that took very large photos. on other devices this would happen "randomly" which is to mean whenever the device ran out of memory and killed our app on the background while the user was on the camera app. reducing the resolution of the photos being taken seemed to make it work much better.

We also saw very specific devices running into this sort of issue. note that some people reported success when using a different camera app, but IIRC from android 11 onwards you can't set a custom default camera app so that workaround was gone.

dimonovdd commented 1 year ago

Hi, Can you try that plugin?

If the problem is not solved, create new issue in that repository. I'll try to fix it.

Don't forget to provide a sample project with this error and the reproduction steps.