react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 Tap to Focus Doesn't work on Android
What's happening?
Whenever I try to call focus function I get the following error message in the catch statement "session/camera-not-ready: [session/camera-not-ready] The Camera is not ready yet! Wait for the onInitialized() callback!]" . Although Camera is ready onInitialized is actually triggered
Reproduceable Code
const device = useCameraDevice('back');
....
const touchToFocus = async (event) => {
if (!device.supportsFocus || !isCameraFocusReady.current) return;
let point = {
x: Math.round(event.pageX - camLocation.x),
y: Math.round(event.pageY - camLocation.y)
};
try {
isCameraFocusReady.current = false;
await cameraRef?.current?.focus(point);
setTimeout(() => {
isCameraFocusReady.current = true;
}, 200);
} catch (error) {
console.log(error)
}
};
.....
<Camera
format={format}
isActive={!paused}
photo={true}
orientation={'portrait'}
focusable={true}
ref={cameraRef}
enableHighQualityPhotos={true}
fps={fps}
preset='photo'
enableZoomGesture={true}
onLayout={handleCameraLayout}
device={device}
zoom={device.neutralZoom}
style={{ flex: 1 }}
onTouchEnd={(x) => touchToFocus(x.nativeEvent)}
/>
Relevant log output
session/camera-not-ready: [session/camera-not-ready] The Camera is not ready yet! Wait for the onInitialized() callback!]
Camera Device
{"sensorOrientation":
"landscape-right",
"hardwareLevel": "full",
"maxZoom": 8,
"minZoom":1,
"supportsLowLightBoost":false,
"neutralZoom":1,
"physicalDevices":["wide-angle-camera"],
"supportsFocus":true,
"supportsRawCapture" true,
"isMultiCam":false,
"name":"BACK(0)",
"hasFlash" true,
"has Torch" true,
"position":"back",
"id":"0"}
Device
OnePlus 5T, Android version 10
VisionCamera Version
3.6.11
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information
- [X] 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.
I am having the same issue, not using expo btw.
Same issue, works fine on ios
Has someone found any solution for this?
Here is the the answer from @mrousavy in another issue: #2003
Yea - duplicate of https://github.com/mrousavy/react-native-vision-camera/issues/2003.