AVFoundation : AVCaptureSession Freeze

2018-01-05 09:33:51.242999-0500 XXXXXXX[987:169984] Capture session runtime error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16811), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c465ddf0 {Error Domain=NSOSStatusErrorDomain Code=-16811 "(null)"}}


I get above code after taking about 10 RAW photos in a row. Camera feed would start getting glitchy and completely would come to a freeze after few more photos.


No other error messages or no memory leaks visible though Instruments.


This doesn't happen with JPEG or any other image formats. Setting up RAW:


let newPhotoSettings = AVCapturePhotoSettings(rawPixelFormatType: OSType(self.photoOutput.availableRawPhotoPixelFormatTypes.first!), processedFormat: [((kCVPixelBufferPixelFormatTypeKey as NSString) as String): NSNumber(value:kCVPixelFormatType_32BGRA)])

newPhotoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: newPhotoSettings.availablePreviewPhotoPixelFormatTypes[0]]

if #available(iOS 11.0, *) { newPhotoSettings.embeddedThumbnailPhotoFormat = [AVVideoCodecKey: newPhotoSettings.availableEmbeddedThumbnailPhotoCodecTypes[0]] }

newPhotoSettings.isHighResolutionPhotoEnabled = true


newPhotoSettings.flashMode = self.flashMode

newPhotoSettings.isAutoStillImageStabilizationEnabled = false

newPhotoSettings.livePhotoMovieFileURL = nil

self.photoOutput.photoSettingsForSceneMonitoring = newPhotoSettings

self.photoOutput.setPreparedPhotoSettingsArray([newPhotoSettings], completionHandler: nil)

Replies

Have you filed a bug? What's the radar number?

I have not filed a bug yet, since I wasn't 100% sure it is not from my end.


I do have Live Photo and Depth modes within the app, trying to make sure changes made to the session from those modes aren't affecting. However, I AM following Apple's sample code samples thoroughly...

I am also having issues with saving the RAW File. When the auto flash is on, flash will fire, but no RAW file will be saved and I have a strong feeling above errors are connected to these as well. I get these errors on iPhone X:


Error capturing photo: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16802), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1cc04f5d0 {Error Domain=NSOSStatusErrorDomain Code=-16802 "(null)"}}

didCapturePhoto

Error capturing photo: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16802), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1cc04f5d0 {Error Domain=NSOSStatusErrorDomain Code=-16802 "(null)"}}

capture completed

2018-01-11 15:45:40.151173-0500 XXXXXXXXX Capture session runtime error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16811), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c0051010 {Error Domain=NSOSStatusErrorDomain Code=-16811 "(null)"}}

Radar 36499817

Hello,


I am having exactly the same error when I try to capture RAW + JPEG image. When flash is disabled, it works fine but if flash is enabled, I am getting the following error:



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


Any idea on how to fix this ?

I am guessing Flash makes a difference in timing of capture. Flash on delays the capture since it has to figure things out and fire. My issue, partly, turned out to AVCapturePhotoSettings getting modified while the capture processes were taking place.

Hello, upgrading to ios 11.4 solved my issue. Tested both on iphone X and iphone 8+.