capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

bug: camera opens after second attempt on Android with using Camera.getPhoto with saveToGallery set to true

Open daniil777555 opened this issue 1 year ago • 6 comments

On newer versions of android camera opens after 2 attempts. I call Camera.getPhoto with option saveToGallery set to true. The the system bottom sheet appears and I choose Take a photo, then the sheet disappears and nothing, I have to click the button again to call Camera.getPhoto and again choose Take a photo. But, if I set saveToGallery to false, everything works as expected. Also worth mentioning that after these manipulations camera opens from the first attempt until I restart the app. I've tried disabling camera permissions and plugin doesn't ask any, I've tried manually request permissions but nothing pops up, I've tried manually enable permissions in settings and bug still presents. And one more thing, I've put console.log after await Camera.getPhoto and nothing appears in console on a first attempt when Camera didn't show off but on second my console.log has been fired.

I've tried to update these things as Android studio suggests despite Capacitor documentation says these versions should be set but it didn't help. classpath 'com.google.gms:google-services:4.4.0' classpath 'com.android.tools.build:gradle:8.2.1' distributionUrl=https://services.gradle.org/distributions/gradle-8.2.1-all.zip

Capacitor dependencies "@capacitor/android": "^6.1.2", "@capacitor/app": "^6.0.1", "@capacitor/camera": "^6.0.2",

daniil777555 avatar Oct 15 '24 11:10 daniil777555

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙

Ionitron avatar Oct 16 '24 08:10 Ionitron

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙

Repository with reproduction https://github.com/daniil777555/capacitor-camera-reproduction

Camera won't open on a first attempt to take a photo. It has been tested on Android APIs 33,34,35 For old versions of Android it works fine

This bug is noticed when saveToGallery is set to true but if it's false then it works

Also additional bug, that Camera.requestPermissions() doesn't request permissions on Android

More detailed explanation, after initial loading or restarting the app, clicking button you see a prompt to choose whether to take a photo or choose from gallery, but after choosing to take a photo, camera won't open you must click the button again and choose Take a photo again, then camera will open. After you did it once, camera will open on a first attempt until you restart the app.

daniil777555 avatar Oct 16 '24 12:10 daniil777555

I have exactly the same problem on new versions of Android. There is also a problem with the permission request, it does not appear. This is critical for my application... Let me know if there is any solution.

JazzShapka avatar Oct 17 '24 08:10 JazzShapka

Facing the exact same issue here. Did someone find a solution?

MatthiasRMS avatar Oct 21 '24 07:10 MatthiasRMS

Facing the exact same issue here. Did someone find a solution?

Nope, waiting for Capacitor team to reply :)

daniil777555 avatar Oct 21 '24 09:10 daniil777555

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

ionitron-bot[bot] avatar Oct 22 '24 16:10 ionitron-bot[bot]

@daniil777555 we just released a new version of @capacitor/camera with the fix. Can you update and test?

alexgerardojacinto avatar Oct 24 '24 16:10 alexgerardojacinto

@daniil777555 we just released a new version of @capacitor/camera with the fix. Can you update and test?

Sure, thanks, I will let you know as soon as I update and test

daniil777555 avatar Oct 25 '24 07:10 daniil777555

@daniil777555 we just released a new version of @capacitor/camera with the fix. Can you update and test?

Hi again, I can confirm that bug with camera is fixed. But there is one small thing that was mentioned in my descriptions. When I call requestPermissions for camera, I don't get the response with Promise, the Promise itself is in an endless resolving or something like that. In my project for reproduction there are few commented lines to demonstrate this case too.

daniil777555 avatar Oct 29 '24 07:10 daniil777555

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Nov 13 '24 07:11 ionitron-bot[bot]