react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 iPhone throws an error when capturing a photo with flash
What's happening?
When I call Camera.takePhoto
and pass { flash: 'on' }
, the camera throws an error every time. When I pass { flash: 'auto' }
the camera throws an error if the surroundings are dim enough that flash is required.
On the first attempt to take a flash photo after activating the camera, the flash will briefly turn on before the error is thrown. On subsequent attempts, the error will throw without the flash turning on at all.
When I pass { flash: 'off' }
, (or { flash: 'auto' }
in well-lit conditions) photo capture works as expected.
The error is:
[capture/unknown: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x285b17600 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-12780), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=The operation could not be completed}]
Reproduceable Code
const photoOptions = {
qualityPrioritization:
photoQualitySetingsMap[photoQualitySetting],
enableAutoStabilization: true,
}
if (device.hasFlash) {
photoOptions.flash = flashSettingsMap[flashSetting]
}
const photo = await camera.current.takePhoto(photoOptions)
Relevant log output
error 13:25:58.029650-0500 audiomxd HALB_IOThread.cpp:44 HALB_IOThread::IsCurrentThread: this thread ought to lock the lock
error 13:25:58.132128-0500 appleh13camerad New connection: pid <private>
error 13:25:58.132172-0500 appleh13camerad Total number of connections: 2
error 13:25:58.132231-0500 appleh13camerad H13ISPServicesAssistant: getProperty 103
error 13:25:58.132256-0500 appleh13camerad H13ISPServicesAssistant: getProperty 103 complete (res=0x00000000)
error 13:25:58.132684-0500 appleh13camerad H13ISPServicesAssistant: getProperty 104
error 13:25:58.132709-0500 appleh13camerad H13ISPServicesAssistant: getProperty 104 complete (res=0x00000000)
error 13:25:58.132989-0500 appleh13camerad Client disconnecting (pid <private>)
error 13:25:58.133013-0500 appleh13camerad Active client pid = 35
error 13:25:58.133037-0500 appleh13camerad Removing client: pid <private>
error 13:25:58.133060-0500 appleh13camerad Total number of connections: 1
error 13:25:58.154325-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-12780)
error 13:25:58.155181-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-12780)
error 13:25:58.155258-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-12780)
error 13:25:58.155487-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.155564-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.155632-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.155699-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.155769-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.156189-0500 mediaserverd <<<< FigCaptureSession >>>> Fig assert: "err == 0 " at bail (FigCaptureSession.m:5448) - (err=-16800)
error 13:25:58.161396-0500 appleh13camerad H13ISPServicesAssistant: setProperty 101
error 13:25:58.161417-0500 appleh13camerad H10ISPServicesAssistant: setProperty 101 complete (res=0x00000000)
error 13:25:58.171710-0500 Phomo CGAffineTransformInvert: singular matrix.
error 13:25:58.226547-0500 appleh13camerad H13ISPServicesAssistant: setProperty 15
error 13:25:58.226571-0500 appleh13camerad H10ISPServicesAssistant: setProperty 15 complete (res=0x00000000)
error 13:25:58.226686-0500 appleh13camerad H13ISPServicesAssistant: setProperty 16
error 13:25:58.226710-0500 appleh13camerad H10ISPServicesAssistant: setProperty 16 complete (res=0x00000000)
error 13:25:58.236066-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:58.236195-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:58.236735-0500 appleh13camerad H13ISPServicesAssistant: setProperty 15
error 13:25:58.236763-0500 appleh13camerad H10ISPServicesAssistant: setProperty 15 complete (res=0x00000000)
error 13:25:58.236892-0500 appleh13camerad H13ISPServicesAssistant: setProperty 16
error 13:25:58.236917-0500 appleh13camerad H10ISPServicesAssistant: setProperty 16 complete (res=0x00000000)
error 13:25:58.238040-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:58.238069-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:58.240909-0500 appleh13camerad H13ISPServicesAssistant: setProperty 15
error 13:25:58.240931-0500 appleh13camerad H10ISPServicesAssistant: setProperty 15 complete (res=0x00000000)
error 13:25:58.241065-0500 appleh13camerad H13ISPServicesAssistant: setProperty 16
error 13:25:58.241090-0500 appleh13camerad H10ISPServicesAssistant: setProperty 16 complete (res=0x00000000)
error 13:25:58.244498-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:58.244524-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:58.333039-0500 appleh13camerad H13ISPServicesAssistant: setProperty 9
error 13:25:58.333082-0500 appleh13camerad H10ISPServicesAssistant: setProperty 9 complete (res=0x00000000)
error 13:25:58.333677-0500 appleh13camerad H13ISPServicesAssistant: setProperty 14
error 13:25:58.333719-0500 appleh13camerad H10ISPServicesAssistant: setProperty 14 complete (res=0x00000000)
error 13:25:58.334016-0500 appleh13camerad H13ISPServicesAssistant: setProperty 15
error 13:25:58.334064-0500 appleh13camerad H10ISPServicesAssistant: setProperty 15 complete (res=0x00000000)
error 13:25:58.334800-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:58.334887-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:58.335699-0500 appleh13camerad H13ISPServicesAssistant: setProperty 10
error 13:25:58.335721-0500 appleh13camerad H10ISPServicesAssistant: setProperty 10 complete (res=0x00000000)
error 13:25:58.389038-0500 audiomxd HALB_IOThread.cpp:44 HALB_IOThread::IsCurrentThread: this thread ought to lock the lock
error 13:25:58.628329-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10
error 13:25:58.628377-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10 complete (res=0x00000000)
error 13:25:58.631548-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10
error 13:25:58.632044-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10 complete (res=0x00000000)
fault 13:25:58.633688-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x776bb64b0> (AutomaticCameraViewfinderSession, PhotoKitService: com.apple.ScreenshotServicesService(1916), 2024-01-14 12:25:49.894-05:00, <PLDelayedActionTimer: 0x776b59e60>(not running)): activate camera session already has an active transaction
fault 13:25:58.636018-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x776812a40> (AutomaticCameraViewfinderSession, PhotoKitService: com.apple.camera(4068), 2024-01-14 13:12:39.287-05:00, <PLDelayedActionTimer: 0x776820b10>(not running)): activate camera session already has an active transaction
fault 13:25:58.636421-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x779b79310> (AutomaticCameraViewfinderSession, PhotoKitService: com.yungchomsky.phomo.dev(4015), 2024-01-14 13:21:42.739-05:00, <PLDelayedActionTimer: 0x779b190f0>(not running)): activate camera session already has an active transaction
error 13:25:58.638309-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10
error 13:25:58.638453-0500 appleh13camerad H13ISPServicesAssistant: getProperty 10 complete (res=0x00000000)
fault 13:25:58.643605-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x7768c0ac0> (AutomaticCameraViewfinderSession, PhotoKitService: com.apple.mobileslideshow(3516), 2024-01-14 12:50:11.836-05:00, <PLDelayedActionTimer: 0x7769a12d0>(not running)): activate camera session already has an active transaction
error 13:25:58.643860-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
fault 13:25:58.646003-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x776e756e0> (AutomaticCameraViewfinderSession, PhotoKitAddService: com.apple.springboard(33), 2024-01-14 12:25:39.400-05:00, <PLDelayedActionTimer: 0x776e12da0>(not running)): activate camera session already has an active transaction
error 13:25:58.647073-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
fault 13:25:58.648880-0500 assetsd <PLCameraCaptureTaskConstraintCoordinator: 0x7798738d0> (AutomaticCameraViewfinderSession, PhotoKitAddService: com.apple.replayd(2283), 2024-01-14 12:50:01.735-05:00, <PLDelayedActionTimer: 0x7798ee810>(not running)): activate camera session already has an active transaction
error 13:25:58.649385-0500 Phomo CGAffineTransformInvert: singular matrix.
error 13:25:58.653511-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
error 13:25:58.653875-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
fault 13:25:58.787585-0500 routined <private>, received location of LoiOverride type, location, <private>
error 13:25:58.787849-0500 symptomsd Source 388950 Unexpected attribution change, was procname remoted pid 3980 epid 3980 uuid 5647DB67-F34A-3535-BA0F-D84A191C361E euuid 5647DB67-F34A-3535-BA0F-D84A191C361E now diagnosticd 4207 4207 DFA69F62-839B-39B9-A7C6-1A05C4BCA191 DFA69F62-839B-39B9-A7C6-1A05C4BCA191
error 13:25:58.787988-0500 symptomsd Source 388950 old attribution remoted new attribution diagnosticd
fault 13:25:58.794030-0500 routined <private>, received location of LoiOverride type, location, <private>
error 13:25:58.819593-0500 symptomsd Source 388889 Unexpected attribution change, was procname remoted pid 3980 epid 3980 uuid 5647DB67-F34A-3535-BA0F-D84A191C361E euuid 5647DB67-F34A-3535-BA0F-D84A191C361E now companion_proxy 4147 4147 74FD734E-E756-37BA-A151-0A2028FEEA1C 74FD734E-E756-37BA-A151-0A2028FEEA1C
error 13:25:58.819643-0500 symptomsd Source 388889 old attribution remoted new attribution companion_proxy
error 13:25:58.819912-0500 symptomsd Source 388883 Unexpected attribution change, was procname remoted pid 3980 epid 3980 uuid 5647DB67-F34A-3535-BA0F-D84A191C361E euuid 5647DB67-F34A-3535-BA0F-D84A191C361E now companion_proxy 4147 4147 74FD734E-E756-37BA-A151-0A2028FEEA1C 74FD734E-E756-37BA-A151-0A2028FEEA1C
error 13:25:58.819936-0500 symptomsd Source 388883 old attribution remoted new attribution companion_proxy
error 13:25:59.084744-0500 mediaserverd Deconv with stride 4 is supported only for SAME mode
error 13:25:59.090006-0500 mediaserverd Deconv with stride 4 is supported only for SAME mode
error 13:25:59.092223-0500 mediaserverd Deconv with stride 4 is supported only for SAME mode
error 13:25:59.210732-0500 appleh13camerad New connection: pid <private>
error 13:25:59.210758-0500 appleh13camerad Total number of connections: 2
error 13:25:59.210808-0500 appleh13camerad H13ISPServicesAssistant: getProperty 103
error 13:25:59.210830-0500 appleh13camerad H13ISPServicesAssistant: getProperty 103 complete (res=0x00000000)
error 13:25:59.210880-0500 appleh13camerad H13ISPServicesAssistant: getProperty 104
error 13:25:59.210947-0500 appleh13camerad H13ISPServicesAssistant: getProperty 104 complete (res=0x00000000)
error 13:25:59.211684-0500 appleh13camerad Client disconnecting (pid <private>)
error 13:25:59.211707-0500 appleh13camerad Active client pid = 35
error 13:25:59.211729-0500 appleh13camerad Removing client: pid <private>
error 13:25:59.211750-0500 appleh13camerad Total number of connections: 1
error 13:25:59.213056-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
error 13:25:59.213444-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
error 13:25:59.284930-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:59.284976-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:59.497284-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:59.497350-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:59.655241-0500 appleh13camerad H13ISPServicesAssistant: setProperty 2
error 13:25:59.655337-0500 appleh13camerad H10ISPServicesAssistant: setProperty 2 complete (res=0x00000000)
error 13:25:59.680397-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
error 13:25:59.681746-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
error 13:25:59.699470-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
error 13:25:59.700690-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
error 13:25:59.703437-0500 appleh13camerad H13ISPServicesAssistant: getProperty 9
error 13:25:59.703619-0500 appleh13camerad H13ISPServicesAssistant: getProperty 9 complete (res=0x00000000)
error 13:25:59.751952-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7
error 13:25:59.754352-0500 appleh13camerad H13ISPServicesAssistant: getProperty 7 complete (res=0x00000000)
error 13:25:59.754475-0500 appleh13camerad H13ISPServicesAssistant: getProperty 9
error 13:25:59.754695-0500 appleh13camerad H13ISPServicesAssistant: getProperty 9 complete (res=0x00000000)
Camera Device
{
"isMultiCam": true,
"minZoom": 1,
"hasTorch": true,
"hardwareLevel": "full",
"position": "back",
"minExposure": -8,
"hasFlash": true,
"name": "Back Triple Camera",
"sensorOrientation": "landscape-right",
"supportsLowLightBoost": false,
"maxExposure": 8,
"formats": [],
"supportsFocus": true,
"physicalDevices": [
"ultra-wide-angle-camera",
"wide-angle-camera",
"telephoto-camera"
],
"neutralZoom": 2,
"supportsRawCapture": false,
"id": "com.apple.avfoundation.avcapturedevice.built-in_video:7",
"maxZoom": 189
}
Device
iPhone 14 Pro iOS 17.2.1
VisionCamera Version
3.7.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
- [X] I am using Expo
- [ ] I have enabled Frame Processors (react-native-worklets-core)
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
lol, weird.
I found a reliable relation to failing to capture photos with flash ON. The test device is iPhone Xr 17.2.1
In format, there is autoFocusSystem
value. It can be phase-detection
or contrast-detection
.
If I use a format with contrast-detection
and flash ON it will error.
If I use a format with phase-detection
and flash ON it takes a picture.
https://react-native-vision-camera.com/docs/api/#autofocussystem ( definitions are taken from apple docs )
My guess right now is contrast-detection
is slower to auto-focus by definition so
- It might be incompatible with flash ON or
- Race condition.
Oh nice research, thanks for getting back here! I'll try to take a look with that info
Btw.; I just merged this PR where you can query for phase-detection
https://github.com/mrousavy/react-native-vision-camera/pull/2455
still getting this issue :(
@ritathesaver can you try to use this format:
const format = useCameraFormat(device, [
{ autoFocusSystem: 'phase-detection' }
])
pass that to the Camera, then try to take a photo and see if that works?
(this API was introduced in VisionCamera 3.9-beta.0)
@ritathesaver can you try to use this format:
const format = useCameraFormat(device, [ { autoFocusSystem: 'phase-detection' } ])
pass that to the Camera, then try to take a photo and see if that works?
(this API was introduced in VisionCamera 3.9-beta.0)
FWIW I just tried this and get the same error in 3.9.0-beta.3. I tried it with two different formats, both using phase-detection:
{"autoFocusSystem": "phase-detection", "fieldOfView": 101.02159118652344, "maxFps": 60, "maxISO": 5472, "maxZoom": 171.875, "minFps": 1, "minISO": 57, "photoHeight": 3024, "photoWidth": 4032, "pixelFormats": ["yuv", "yuv", "rgb", "unknown", "yuv", "unknown", "yuv", "unknown", "rgb"], "supportsDepthCapture": false, "supportsPhotoHdr": false, "supportsVideoHdr": false, "videoHeight": 768, "videoStabilizationModes": ["auto", "off", "standard"], "videoWidth": 1024}
{"autoFocusSystem": "phase-detection", "fieldOfView": 103.62532043457031, "maxFps": 30, "maxISO": 12768, "maxZoom": 189, "minFps": 1, "minISO": 57, "photoHeight": 3024, "photoWidth": 4032, "pixelFormats": ["yuv", "yuv", "rgb", "unknown", "yuv", "unknown", "yuv", "unknown", "rgb"], "supportsDepthCapture": false, "supportsPhotoHdr": false, "supportsVideoHdr": false, "videoHeight": 3024, "videoStabilizationModes": ["auto", "off"], "videoWidth": 4032}
When I try to take a flash photo I get:
[capture/unknown: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x281d3c480 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16800), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=The operation could not be completed}]
@mrousavy I do not know if it is related! Note what is going on in "pixelFormats": ["yuv", "yuv", "rgb", "unknown", "yuv", "unknown", "yuv", "unknown", "rgb"],
@stevengoldberg did you try to change enableShutterSound
?
Does the flash work correctly when using a third party app like Instagram, Snapchat or WhatsApp?
Yes — I just tested with Instagram.
@mrousavy I just tested this on an iPhone 15 Pro running iOS 17.4 and the error is the same. autoFocusSystem is phase-detection. It occurs whether enableShutterSound is true or false.
Another data point — I tried expo-camera/next
in my app with no other changes and the flash works there, too (iPhone 15 Pro).
Yea, because expo-camera does not support formats at all.
On VisionCamera you can fix this by selecting a different format - there are some formats that work, some that don't. I've seen that stuff like maxISO affects it.
I'm trying to fix the issue where some formats don't work, but I haven't dedicated the time to do that yet.
I have the same problem on an iPhone 12 mini. A fix would be very welcome.
Re: 3.9.2
TakePhotoOption notes:
-Passing flash causes Android photo capture to lag ~5 seconds minimum. -Passing enableAutoDistortionCorrection causes iOS app to crash.
Passing no options works great! Seems fixed in v4.0.1 though.
I updated to 4.0.4 and flash is now working as expected on an iPhone 15 Pro 🎉
I still getting the issue I'm using react-native-vision-camera version 4.3.2, iPhone XS Is there any workaround?