mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.57k stars 1.1k forks source link

🐛 AVFoundationError -11819 #3245

Open tgreco opened 1 month ago

tgreco commented 1 month ago

What's happening?

When taking a photo randomly I get this error thrown.

image

image

Reproduceable Code

const takePhotoResult = await cameraRef.current.takePhoto({
          flash: 'off',
          enableAutoRedEyeReduction: false,
          enableAutoDistortionCorrection: false,
});

 <ReanimatedCamera
                ref={cameraRef}
                style={styles.fill}
                device={device}
                format={format}
                fps={FRAMES_PER_SEC}
                videoHdr={format?.supportsVideoHdr}
                photoHdr={format?.supportsPhotoHdr}
                // lowLightBoost={device.supportsLowLightBoost && isNightMode}
                isActive={isActive}
                onInitialized={onInitialized}
                onError={onError}
                enableZoomGesture={false}
                animatedProps={cameraAnimatedProps}
                photo
                video={mediaType === MediaType.video}
                audio={hasMicrophonePermission && mediaType === MediaType.video}
                enableLocation
                photoQualityBalance="speed"
              />

Relevant log output

[capture/unknown: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x302afbf30 {Error Domain=NSOSStatusErrorDomain Code=-16802 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16802), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=The operation could not be completed}]

If I try to print the error description I get this nonsense:

description of error:
error: type for self cannot be reconstructed: type for typename "$s12VisionCamera7PromiseCD" was not found
error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work.

Camera Device

{
  "position": "back",
  "maxZoom": 123.75,
  "hasTorch": true,
  "formats": [],
  "supportsLowLightBoost": false,
  "maxExposure": 8,
  "sensorOrientation": "portrait",
  "isMultiCam": true,
  "minZoom": 1,
  "minFocusDistance": 2,
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:7",
  "hasFlash": true,
  "name": "Back Triple Camera",
  "minExposure": -8,
  "hardwareLevel": "full",
  "supportsFocus": true,
  "supportsRawCapture": false,
  "neutralZoom": 2,
  "physicalDevices": [
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera"
  ]
}

Device

iPhone 16 - ios 18.1

VisionCamera Version

4.5.3

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 1 month ago

Guten Tag, Hans here 🍻

Thanks for reporting ze issue! It looks like you’ve already provided some helpful information, but we do need a bit more to help you effectively.

Could you please confirm if you are able to reproduce zis issue in ze VisionCamera Example app? It’s important to test zis, as it can help narrow down if it’s an issue with your implementation or ze library itself.

Also, please make sure to provide any relevant logs from Xcode, as they can be very useful in diagnosing ze problem. You can find ze logs in Xcode's Output window while running your app.

If you have not tried these steps yet, I recommend doing so, and if ze problem persists, we can take a deeper look together.

Danke!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

iliapnmrv commented 1 week ago

Hey! I have the same issue in Sentry (400+ times, 150+ users), cannot reproduce in dev though. I'm using code scanner

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

const format =
  device &&
  getCameraFormat(device, [
    {fps: 20},
    {videoAspectRatio: screenAspectRatio},
    {videoResolution: 'max'},
    {photoAspectRatio: screenAspectRatio},
    {photoResolution: 'max'},
    {autoFocusSystem: 'contrast-detection'},
  ]);
<GestureDetector gesture={tap}>
      <Camera
        format={format}
        zoom={device.neutralZoom}
        device={device}
        ref={cameraRef}
        isActive={isActive}
        onError={onError}
        codeScanner={codeScanner}
      />
</GestureDetector>
{
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:7",
  "maxZoom": 123.75,
  "sensorOrientation": "portrait",
  "minFocusDistance": 2,
  "position": "back",
  "formats": [],
  "supportsFocus": true,
  "supportsRawCapture": false,
  "neutralZoom": 2,
  "physicalDevices": [
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera"
  ],
  "hardwareLevel": "full",
  "isMultiCam": true,
  "hasTorch": true,
  "supportsLowLightBoost": false,
  "maxExposure": 8,
  "name": "Rear triple camera",
  "hasFlash": true,
  "minExposure": -8,
  "minZoom": 1
}
"react-native-vision-camera": "^4.5.2",
"react-native": "^0.75.4"

@tgreco Did you manage to find a solution?

tgreco commented 1 week ago

No solution as of yet unfortunately