react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

🐛 Crash on device without any cameras

Open alkhatera opened this issue 2 years ago • 1 comments

What's happening?

When I used the package with a device that had cameras, it worked perfectly. However, when run with any device without cameras, as soon as the app starts it crashes.

Reproduceable Code

const cameraRef = React.useRef<Camera | null>(null);
const devices = useCameraDevices();

const [cameraType, setCameraType] = React.useState<CameraDevice | null>(
    devices.length ? devices[0] : null,
  );

const codeScanner = useCodeScanner({
    codeTypes: ['code-128', 'code-39', 'code-93', 'codabar', 'ean-13', 'ean-8'],
    onCodeScanned: codes => {
      onReadBarcode(codes[0].value || '');
    },
  });

return <View>
<RNCamera
          ref={cameraRef}
          device={cameraType}
          isActive
          audio={false}
          focusable
          codeScanner={codeScanner}
          enableZoomGesture
          resizeMode="cover"
        />
</View>

Relevant log output

Camera LENS_FACING_FRONT verification failed java.lang.IllegalArgumentException: No available camera can be found at androidx.camera.core.CameraSelector.select(CameraSelector.java:107) at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:124) at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:336) at androidx.camera.core.CameraX$$ExternalSyntheticLambda0.run(Unknown Source:12) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)

Camera Device

No cameras in device

Device

iMin Swan

VisionCamera Version

^4.4.1

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

alkhatera avatar Jul 10 '24 11:07 alkhatera

Guten Tag, Hans here.

Looks like 'ya left out some information! Make sure to add enough details to the following section:

  • Camera Device

[!NOTE] New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time. To support @mrousavy, please consider 💖 sponsoring him on GitHub 💖. Sponsored issues will be prioritized.

maintenance-hans avatar Jul 10 '24 11:07 maintenance-hans