AVUnknown error using Camera Extensions in AVCaptureSession

I have a Mac Catalyst video conferencing app that streams video using AVCaptureMultiCamSession. Everything has been working well for me in a variety of scenarios and hardware, but recently I got a report that virtual cameras / camera extensions do not seem to work - which I can reproduce 100% of the time by using something like OBS's virtual camera. FaceTime and Photo Booth work okay with these virtual cameras. Although my app can see and add the external AVCaptureDevice, I get an AVCaptureSessionRuntimeError posted when I start the session with a connection between the virtual camera and a AVCaptureVideoDataOutput (I don't get the error if I don't connect or add an output). The posted error is AVUnknown:

AVCaptureSessionRuntimeErrorNotification with 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=0x600001dcd680 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}}

Which doesn't tell me too much. I do see some fig assertions just above in Console though:

<<<< BWMultiStreamCameraSourceNode >>>> Fig assert: "err == 0 " at bail (BWMultiStreamCameraSourceNode.m:3964) - (err=-12780)
<<<< BWMultiStreamCameraSourceNode >>>> Fig assert: "err == 0 " at bail (BWMultiStreamCameraSourceNode.m:1591) - (err=-12780)
<<<< BWMultiStreamCameraSourceNode >>>> Fig assert: "err == 0 " at bail (BWMultiStreamCameraSourceNode.m:1418) - (err=-12780)
<<<< FigCaptureCameraSourcePipeline >>>> Fig assert: "err == 0 " at bail (FigCaptureCameraSourcePipeline.m:3572) - (err=-12780)
<<<< FigCaptureCameraSourcePipeline >>>> Fig assert: "err == 0 " at bail (FigCaptureCameraSourcePipeline.m:4518) - (err=-12780)
<<<< FigCaptureCameraSourcePipeline >>>> Fig assert: "err == 0 " at bail (FigCaptureCameraSourcePipeline.m:483) - (err=-12780)

I've verified formats are sane (the usual 420v 1080p 30fps I have everywhere else) and data output functions and such, but I'm a bit stuck as to where to go from here.

One thing that did stand out is that in the AVCamBarcode example I can see the virtual camera in that app's preview layer, but if I create an AVCaptureVideoDataOutput and add it to the session in that example, it fails in what looks like exactly the same way that my app does, with the same assertions.

Does anyone have any advice? Thanks!

Answered by DTS Engineer in 806064022

Hello @RichLogan,

Thanks for the reproducible case, I was able to reproduce the issue, though I should note that the error does not occur with every camera extension, but it does occur for many (including the Camera Extension template).

Please file a bug report for this issue and post your Feedback number back on this thread.

Best regards,

Greg

The repro in the AVCamBarcode (https://developer.apple.com/documentation/avfoundation/capture_setup/avcambarcode_detecting_barcodes_and_faces) sample app is to:

  1. Enable and switch to Mac Catalyst as a destination
  2. Add the following lines to CameraViewController.swift:220
  3. Use a camera extension.

With the commented out line you will see the preview correctly and as expected. Uncomment the line to add an output and everything will break.

let output = AVCaptureVideoDataOutput()
guard session.canAddOutput(output) else {
    fatalError()
}
// session.addOutput(output) // Uncomment this line for everything to break. 

Hello @RichLogan,

Thanks for the reproducible case, I was able to reproduce the issue, though I should note that the error does not occur with every camera extension, but it does occur for many (including the Camera Extension template).

Please file a bug report for this issue and post your Feedback number back on this thread.

Best regards,

Greg

@DTS Engineer

Thanks Greg, feedback filed in FB15294117.

Out of interest, were there any Camera Extensions you know of that worked that provide virtual cameras? I ended up rewriting against native MacOS to see it work as a temporary workaround, but if there is a known virtual camera extension that works it would be great to be able to provide an alternative solution to my users. No worries if not.

Thanks for the quick response!

Hey @RichLogan,

"virtual camera" is a bit of an overloaded term, so I'll use the terminology introduced in Create camera extensions with Core Media IO, namely, "pure software cameras" and "creative cameras".

I reproduced the issue with the pure software camera provided in the Camera Extension template, but was unable to reproduce using a "creative camera".

Best regards,

Greg

AVUnknown error using Camera Extensions in AVCaptureSession
 
 
Q