Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

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

Open nebeskm opened this issue 4 years ago • 9 comments

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

  • version of Xamarin.Essentials 1.7.0
  • Android 11
  • Affected Devices: Samsung SM-T510

nebeskm avatar Sep 15 '21 11:09 nebeskm

This also happens in App-Essentials Sample App

nebeskm avatar Sep 15 '21 11:09 nebeskm

Hi! I have been also having this trouble!

Did find any solution on that?

Cheers!

Brunoporto2702 avatar Oct 28 '21 12:10 Brunoporto2702

Any news on this topic ?

lukaszfuturum avatar Nov 30 '21 13:11 lukaszfuturum

Still no solution?

SilvioLuizGuimaraes avatar Feb 09 '22 13:02 SilvioLuizGuimaraes

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

nebeskm avatar Apr 14 '22 06:04 nebeskm

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

Jerome-Liger avatar Jul 08 '22 14:07 Jerome-Liger

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

wx0322 avatar Oct 25 '22 10:10 wx0322

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.

MitchBomcanhao avatar Nov 01 '22 15:11 MitchBomcanhao

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.

dimonovdd avatar Dec 05 '22 22:12 dimonovdd