expo-camera autoFocus failed error

when i am navigating from page A to B (A->B) and then returning from B to A (B->A) and trying to take picture getting error:
[Error: Call to function ‘ExponentCamera.takePicture’ has been rejected.Caused by: java.lang.RuntimeException: autoFocus failed]

when when I am first time on A, I am able to take picture. And this is only happening on Android

This error seems to be related to the Camera component not being properly unmounted when you navigate away from the page where it is being used.

export default function CameraPage() {
  let cameraRef = useRef(null);

  useEffect(() => {
    return () => {
      if (cameraRef.current) {
        cameraRef = null;
  }, []); 

  return <Camera ref={cameraRef} />;

Hopefully it will help you :smiley: