mrousavy / react-native-vision-camera

πŸ“Έ A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
6.93k stars 1.02k forks source link

πŸ› [iOS] TypeError: Cannot read property 'CameraDevices' of undefined #3048

Open short-dsb opened 4 days ago

short-dsb commented 4 days ago

What's happening?

Trying to invoke useCameraDevice on an iOS simulator in 4.4.1 results in a JS exception:

Error: Exception in HostObject::get: for prop 'CameraDevices': , js engine: hermes TypeError: Cannot read property 'CameraDevices' of undefined

This issue was not present in 4.4.0.

Reproduceable Code

const device = useCameraDevice("back", {
  physicalDevices: [
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera",
  ],
});

<Camera
  ref={camera}
  device={device}
  enableZoomGesture={true}
  isActive={isActive}
  photo={true}
  resizeMode="contain"
  style={styles.camera}
/>

Relevant log output

13:06:01.742: [error] πŸ“Έ VisionCamera.physicalDeviceDescriptor: Unknown AVCaptureDevice.DeviceType ()! Falling back to wide-angle-camera..

Camera Device

// N/A the exception prevents this from being logged.

Device

iPhone 15 simulator (iOS 17.2)

VisionCamera Version

4.4.1

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

maintenance-hans[bot] commented 4 days ago

Guten Tag, Hans here.

[!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.

rubbishCoder commented 2 days ago

@short-dsb try downgrading to the below version, it worked for me

"react-native-vision-camera": "4.4.0"

fleuverouge commented 1 day ago

@short-dsb try downgrading to the below version, it worked for me

"react-native-vision-camera": "4.4.0"

Version 4.4.0 has issues with orientations in older iOS so it's not an option.

Dat-Mobile commented 1 day ago

I'm using this as the workaround, wait for the crash to fix in the next version

import DeviceInfo from 'react-native-device-info'

const device = DeviceInfo.isEmulator() ? null : useCameraDevice("back");