From 2f65ac143782ee7f57b2b5ee3a9981d5843ed1f8 Mon Sep 17 00:00:00 2001 From: Jon Hjelle Date: Fri, 12 Jun 2015 11:33:45 -0700 Subject: [PATCH] Fix crash and warning in AppRTCDemo Don't dismiss the presented view controller if it's already being dismissed to clear a warning about dismissing from a view controller while a dismiss is in progress. Remove the sample buffer delegate when capture is being stopped to avoid a crash when a delegate method is sent to a deallocated object. BUG=webrtc:4734 R=jiayl@webrtc.org, tkchin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/54669004. Patch from Jon Hjelle . Cr-Commit-Position: refs/heads/master@{#9430} --- talk/app/webrtc/objc/avfoundationvideocapturer.mm | 1 + .../objc/AppRTCDemo/ios/ARDVideoCallViewController.m | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.mm b/talk/app/webrtc/objc/avfoundationvideocapturer.mm index bd472a498a..d68fdff79a 100644 --- a/talk/app/webrtc/objc/avfoundationvideocapturer.mm +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.mm @@ -142,6 +142,7 @@ static dispatch_queue_t kBackgroundQueue = nil; if (!_isRunning) { return; } + [_videoOutput setSampleBufferDelegate:nil queue:nullptr]; AVCaptureSession* session = _captureSession; dispatch_async(kBackgroundQueue, ^{ [session stopRunning]; diff --git a/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m b/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m index b12a61a618..2f07c7a4cc 100644 --- a/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m +++ b/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m @@ -151,8 +151,10 @@ self.remoteVideoTrack = nil; self.localVideoTrack = nil; [_client disconnect]; - [self.presentingViewController dismissViewControllerAnimated:YES - completion:nil]; + if (![self isBeingDismissed]) { + [self.presentingViewController dismissViewControllerAnimated:YES + completion:nil]; + } } - (void)switchCamera {