🐛 [device/flash-not-available: The Camera Device does not have a flash unit! Make sure you select a device where `device.hasFlash`/`device.hasTorch` is true.]
What's happening?
The back camera is working for me, but I am experiencing this issue when using the front camera to take selfies. I am using getCameraDevice(devices, 'front') to obtain the front camera. I would appreciate your guidance in fixing this or letting me know if anything is incorrect.
Reproduceable Code
const frontDevice = getCameraDevice(devices, 'front');
<Camera
ref={ref => {
this.camera = ref;
}}
style={cameraStyle}
device={frontDevice}
isActive={isActive}
photo={true}
torch={"off"}
enableZoomGesture={true}
/>
Relevant log output
error [device/flash-not-available: The Camera Device does not have a flash unit! Make sure you select a device where `device.hasFlash`/`device.hasTorch` is true.]
Camera Device
{
"formats": [],
"sensorOrientation": "landscape-right",
"hardwareLevel": "full",
"maxZoom": 4,
"minZoom": 1,
"maxExposure": 12,
"supportsLowLightBoost": false,
"neutralZoom": 1,
"physicalDevices": [
"wide-angle-camera"
],
"supportsFocus": true,
"supportsRawCapture": false,
"isMultiCam": false,
"minFocusDistance": 0,
"minExposure": -24,
"name": "1 (FRONT) androidx.camera.camera2",
"hasFlash": false,
"hasTorch": false,
"position": "front",
"id": "1"
}
Device
Xiaomi Redmi Note 8 Pro - M1906G71
VisionCamera Version
4.5.2
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information
- [ ] I am using Expo
- [ ] I have enabled Frame Processors (react-native-worklets-core)
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
Guten Tag, Hans here! 🍻
It looks like you are encountering an issue with ze front camera on your Xiaomi Redmi Note 8 Pro. From ze logs, it seems like ze device does not have a flash unit, which is correct; ze hasFlash and hasTorch properties are both false.
If you need ze flash for your selfies, perhaps you might consider using ze back camera instead, as it typically has a flash. If you are looking for assistance beyond this, please provide additional logs from adb logcat or any other debugging information to help mrousavy troubleshoot further!
Otherwise, it might be wise to check out ze Troubleshooting Guide in more detail. Also, if you wish for priority response, consider sponsoring the project here.
Keep up ze good work!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
@mrousavy Thank you for your prompt response. As I do not intend to use a flash or torch while using the front camera, why is it still necessary that device.hasFlash and device.hasTorch be true? Also, I have used the torch={"off"} property, so why is this issue still occurring?
~~If you don't have a device you shouldn't render the Camera. This is literally what the error message says. Use Typescript, you cannot pass null to device~~
EDIT: Sorry I didn't read the whole issue - maybe it works when yoh pass torch={undefined}?
@mrousavy i am not passing null to device prop. I am passing the which is return by getCameraDevice(devices, 'front') and camera view is opened in my app but takePhoto function is not working for me. So i have changed in the options flash: 'off' like below and now its working for me.
const options = { base64: false, flash: 'off', skipMetadata: true };
let response = await this.camera.takePhoto(options);
Ran into this and burned some hours digging through to find this.
My issue was any references to cameraRef just silently failed on older android devices. Turns out, it was down to flash being set to auto. Worked fine in iOs and newer Android devices but not in some older devices.
The solution was to verify if the device supports flash before enabling flash: auto when capturing a photo. I was under the assumption flash: auto would have done this check.
请问解决了嘛 我也有这个问题
huawei 手机都不行
i test the huawei devices can't work
我也是华为机不行 用react-native-torch灯光灯库 针对华为机做了单独处理, 其他机型下用vision-camera自带的 目前正常
I am also experiencing this issue:
- With
[email protected] - On Android devices (including Pixel 6, Pixel 8 Pro, Pixel 9 Pro, and others)
- Using the "rear" camera
- Calling
takePhoto({ enableShutterSound: false, flash: 'off' })
The device/flash-not-available error is raised.
Im encountering a similar issue, but it seems specifically with the back ultra wide camera, it works fine on the others. I've worked out to detect and pass false.
I think the bahviour is correct, but in V2 you could pass true and it would ignore it if the device had no flash.