Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sdk/objc/components/capturer/RTCCameraVideoCapturer.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,17 @@ - (void)stopCaptureWithCompletionHandler:(nullable void (^)(void))completionHand
RTCLogInfo("Stop");

#if TARGET_MULTICAM_CAPABLE
[self.captureSession removeConnection:self->_captureConnection];
self->_captureConnection = nil;
if (self->_captureConnection) {
// We only try to remove the connection if it's still in the session. By doing that
// we avoid a crash if the connection was already removed (e.g. in the case of
// a multi-camera setup).
// The crash looks like this:
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureSession removeConnection:] <(null): 0x0> does not exist in this session'
if ([self.captureSession.connections containsObject:self->_captureConnection]) {
[self.captureSession removeConnection:self->_captureConnection];
}
self->_captureConnection = nil;
}
#endif

for (AVCaptureDeviceInput *oldInput in [self.captureSession.inputs copy]) {
Expand Down