On client phones rarely can be replicated crash during camera dealloc
Fatal Exception: NSRangeException
Cannot remove an observer <AVCaptureSession 0x174212170> for the key path "changeSeed" from <AVCaptureConnection 0x17420fa60> because it is not registered as an observer.
Thread : Fatal Exception: NSRangeException
0 CoreFoundation 0x000000018449259c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x0000000194be40e4 objc_exception_throw + 60
2 CoreFoundation 0x00000001844924dc -[NSException initWithCoder:]
3 Foundation 0x00000001852a7e9c -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 528
4 Foundation 0x00000001852a7954 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 104
5 AVFoundation 0x0000000182d21054 -[AVCaptureSession _removeConnection:] + 192
6 AVFoundation 0x0000000182d206dc -[AVCaptureSession _removeVideoPreviewLayer:] + 120
7 AVFoundation 0x0000000182d300f8 -[AVCaptureVideoPreviewLayer dealloc] + 92
For stop capture session following code is used: All operation with session are precessed in background queue, as stopRunning can take some time
deinit {
if let session = self.captureSession {
dispatch_async(self.cameraQueue, { () -> Void in
session.beginConfiguration()
let allInputs = session.inputs as! [AVCaptureInput]
for input in allInputs {
session.removeInput(input)
}
let allOutputs = session.outputs as! [AVCaptureOutput]
for output in allOutputs {
session.removeOutput(output)
}
session.commitConfiguration()
session.stopRunning()
})
}
}
Has anybody seen this crash before?
stopRunning()
? – Frere