In iOS 12.1, my App is crashed when using background camera by API (AVCaptureSession.addInput).
Is there any difference in iOS 12.1?
The code is like blew:
// check camera device input.
if (deviceInput != nil) {
[captureSession removeInput:deviceInput];
}
// set camera device input to capture session.
NSError *error = nil;
deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_camera error:&error];
if (error != nil) {
return;
}
if (deviceInput == nil) {
return;
}
[captureSession addInput:deviceInput];
// set video preview layer to camera view.
videoPreviewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.layer insertSublayer:videoPreviewLayer atIndex:0];
The exception information is:
-[AVCaptureSession addInput:] Multiple audio/video AVCaptureInputs are not currently supported
It crashed only when using background camera.(If use front camera, it is OK.)
And it only happened in some iPad Pro devices.(iPad Pro 11'' 2018, iPad Pro 12.9'' 2018).