react-native-vision-camera: 🐛 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

About this issue

  • Original URL
  • State: open
  • Created 6 months ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

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

  1. It might be incompatible with flash ON or
  2. Race condition.

Btw.; I just merged this PR where you can query for phase-detection https://github.com/mrousavy/react-native-vision-camera/pull/2455

Oh nice research, thanks for getting back here! I’ll try to take a look with that info