Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
daniil777555 opened this issue Oct 15, 2024 · 8 comments · Fixed by #2222
Labels
needs reproduction type: bug A confirmed bug report

Comments

@daniil777555
Copy link

daniil777555 commented Oct 15, 2024

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",

@Ionitron
Copy link
Collaborator

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 💙

@daniil777555
Copy link
Author

daniil777555 commented Oct 16, 2024

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.

@JazzShapka
Copy link

JazzShapka commented Oct 17, 2024

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.

@MatthiasRMS
Copy link

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

@daniil777555
Copy link
Author

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

Nope, waiting for Capacitor team to reply :)

@alexgerardojacinto alexgerardojacinto added the type: bug A confirmed bug report label Oct 22, 2024
Copy link

ionitron-bot bot commented Oct 22, 2024

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.

@alexgerardojacinto alexgerardojacinto changed the title Camera opens after second attempt on Android bug: camera opens after second attempt on Android with using Camera.getPhoto with saveToGallery set to true Oct 22, 2024
@alexgerardojacinto
Copy link
Collaborator

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

@daniil777555
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction type: bug A confirmed bug report
Projects
None yet
5 participants