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

🐛 When taking a photo the capture fails with error `-11800: The operation could not be completed`

Open LESANF opened this issue 8 months ago • 14 comments

What's happening?

Please watch the video below.

https://github.com/mrousavy/react-native-vision-camera/assets/54767632/13da3839-c112-45dc-ae5e-d751797b3bd8

https://github.com/mrousavy/react-native-vision-camera/assets/54767632/1621cc18-65ea-4c56-9abd-9ffc7d498786

========================================================================================

The error only occurs under completely specific conditions.

In my opinion, this condition is when using IOS17 or higher on iPhone 14

The error did not occur when using IOS16 on iPhone 14.

I can't confirm that it's a bug in IOS17. Because when using IOS17 on other devices such as SE, 12, etc., the bug does not occur.

I want to know what the problem is.

The build took place in xcode14.2.

Reproduceable Code

const device = useCameraDevice('back');

try { 
    if (tempPath === '') {
         setIsActive(false);
         const photo =
             Platform.OS === 'ios'
                 ? await cameraRef.current.takePhoto({
                      flash: 'off',
                     })
                 : await cameraRef.current.takeSnapshot({
                      quality: 80,
                      flash: 'off',
                    });
                
        let rotatedUri = photo.path;

        await foodLensProcess(rotatedUri);
    }  else {
           setTempPath('');
           setFoodInfo(null);
           setUploadPath('');
           setIsActive(true);
    }
} catch (err) {
    alert(err);
    console.log('takePhoto catch :', err);
}

<Camera
    ref={cameraRef}
    style={StyleSheet.absoluteFill} 
    device={device}
    isActive={isActive}
    photo={true}
/>

Relevant log output

Error Domain=AVFoundationErrorDomain Code=-11800 The operation could not be completed UserInfo={NSUnderlyingError=0x28006b360 { Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=Anunknown error occurred (-16800), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=The operation could not be completed}

Camera Device

-

Device

iPhone 14 Pro(IOS 17.0.2, 17.0.3)

VisionCamera Version

3.3.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

LESANF avatar Oct 12 '23 06:10 LESANF

@mrousavy Thank you for changing the title

LESANF avatar Oct 12 '23 10:10 LESANF

Is this related to https://github.com/mrousavy/react-native-vision-camera/issues/1923?

mrousavy avatar Oct 16 '23 15:10 mrousavy

As per this StackOverflow post:

Having your device restrict the camera access under "Settings > General > Restrictions" will also give you this error.

Could it be that the user disabled Camera access? In that case, useCameraPermission() would probably return "restricted". Do you check for that?

mrousavy avatar Oct 16 '23 15:10 mrousavy

Also maybe searching for this error on StackOverflow could be any help. If you find anything useful that works for you, please let me know!

mrousavy avatar Oct 16 '23 15:10 mrousavy

@mrousavy

As per this StackOverflow post:

Having your device restrict the camera access under "Settings > General > Restrictions" will also give you this error.

Could it be that the user disabled Camera access? In that case, useCameraPermission() would probably return "restricted". Do you check for that?


First of all, thank you for replying.

It looks similar to the #1923 you told me, but I think it's a little different

But it looks very similar, but the reason why my answer might be ambiguous is that I haven't figured out the exact cause yet

I tested it with a lot of IOS models and found the exact case

Only with 14 or higher and at the same time with IOS 17 or higher.

It worked exactly on iPhone 14 Pro and IOS 16 versions. I've tested several iPhone 14 Pro models

You gave me an opinion about permission and I've already tested it. If you didn't grant the camera permission, the camera components themselves from vision shouldn't have appeared But Component worked fine and it's an error log from the takephoto method

I still haven't solved this problem

Eventually, I replaced the library with react-native-camera.

I'm curious about the cause, too

LESANF avatar Oct 16 '23 17:10 LESANF

@mrousavy I'm sorry, I accidentally clicked on 'closed'

LESANF avatar Oct 16 '23 17:10 LESANF

We have similar issues with the QR code scanner on iOS. Permission has been given.

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

Version: 3.5.1 Model: iPhone 11 OS: 15.6.1

kcstechnis avatar Oct 24 '23 06:10 kcstechnis

I am having a similar problem on Iphone 15, 17.02

<Camera
    photo
    isActive
    enableHighQualityPhotos
    video={false}
    audio={false}
    ref={camera}
    device={device}
    style={{flex: 1}}/>
    
    await camera.current.takePhoto({ flash: 'off' })

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x2803dbdb0 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16800)

siemya avatar Oct 26 '23 15:10 siemya

Same error on iPhone 15 Pro Max - iOS 17.1

<Camera ref={camera} photo={true} style={styles.camera} device={device} isActive={isFocused} />

const photo = await camera.current.takePhoto({ flash: 'off', });

[capture/unknown: Error Domain=AVFoundationErrorDomain Code=-11800 "L’operazione non è stata completata" UserInfo={NSUnderlyingError=0x2803994a0 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=Si è verificato un errore sconosciuto (-16800), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=L’operazione non è stata completata}]

michelevettone avatar Oct 30 '23 10:10 michelevettone

Same with iPhone XR on IOS 17.1.1

AndreaLiboni avatar Nov 15 '23 00:11 AndreaLiboni

I have this problem too, iOS 17.1.1 in a native app (swiftui). In my case it works sometimes. So it looks like some kind of timing error. I seem to solve the problem by setting photoSettings.photoQualityPrioritization = .speed // instead of .quality

Not sure that setting is accessible here, but just trying to solve the same problem sort of.

poromaa avatar Nov 15 '23 17:11 poromaa

I am getting bellow error while capture video in iPhone 11 and iOS 17.1.1 but it is working in iPhone 13 Pro Max and iOS 17.1.1.

capture/unknown: An unknown recording error occured! Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x28391f9f0 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}}

akshaypingala avatar Nov 21 '23 05:11 akshaypingala

Hey,

having the same pb with iOS 17.1.1 & iPhone 13 Pro It's happening randomly

Thx

IvanByRool avatar Dec 02 '23 22:12 IvanByRool

Hey! Same here with iphone 15(pm), iOS 17.1.2(Native Swift)

photoSettings.photoQualityPrioritization = .speed // instead of .quality

thank you very much! This is resolved for now. I spent the entire week debugging this.

randbytes avatar Dec 04 '23 08:12 randbytes

Hey! Closing for now as I think this has been fixed in recent VisionCamera updates. If you still experience this error, please re-open this.

mrousavy avatar Jan 15 '24 13:01 mrousavy

If not, this might be an Apple bug: https://forums.developer.apple.com/forums/thread/717565

mrousavy avatar Jan 15 '24 13:01 mrousavy

Having issue again on v3.6.16 on all iOS devices.

Adding qualityPrioritization: 'speed' to options while taking a picture fixes it. but not sure why its happening in the first place

vishaljak avatar Feb 19 '24 05:02 vishaljak

but not sure why its happening in the first place

Me neither.

Adding qualityPrioritization: 'speed' to options while taking a picture fixes it.

great! Maybe this will be fixed in future iOS update.s

mrousavy avatar Feb 19 '24 11:02 mrousavy