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)