fix: [Android] No available camera on some Samsung devices#3691
fix: [Android] No available camera on some Samsung devices#3691moonjava2005 wants to merge 2 commits intomrousavy:mainfrom
Conversation
|
@moonjava2005 is attempting to deploy a commit to the mrousavy's Team Team on Vercel. A member of the Team first needs to authorize it. |
|
I’ve been running into the same issue on Android, mainly on Samsung devices, where useCameraDevices() intermittently returns an empty list on cold start and the camera never becomes available. I tested this fix by patching it onto react-native-vision-camera@4.7.3 in an Expo SDK 51 / React Native 0.74.5 app, and it reliably resolves the problem across repeated launches. For reference, this is happening on production devices (Galaxy A53 5G / SM-A536U, Android 16). The fallback to querying the camera provider at runtime instead of relying on getConstants() makes a lot of sense given how intermittent the race condition is. Thanks for putting this together — this has been a real pain point on these devices. |
|
Good day, I will apply the suggested patch; it doesn't seem like the maintainer is going to fix it anytime soon. |
What
useCameraDevices()always returns an empty device list.Why
getConstants(), thecameraProvidermay not be fully initialized yet, causing the exported device list to be empty.If such events are sent too early, the JS layer will never receive them, resulting in a permanently empty device list.
How
Add a new exported native method to retrieve the current camera device list directly from
cameraProvider, instead of relying solely on the one-time value fromgetConstants().Update the JS hook logic on Android only:
useCameraDevices()returns an empty list, the hook will manually invoke this native method to fetch the latest available devices.This ensures the device list is always retrieved from the latest and fully initialized camera state, eliminating the race condition.