From e8daf9a8d33987aa45fc4fa9240a071dffd4f4c1 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 12 Sep 2017 16:57:42 -0400 Subject: [PATCH 1/3] Fix assert when missing camera permission during calls. // FREEBIE --- Signal/src/call/PeerConnectionClient.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/call/PeerConnectionClient.swift b/Signal/src/call/PeerConnectionClient.swift index 859eacd03..f869ac30b 100644 --- a/Signal/src/call/PeerConnectionClient.swift +++ b/Signal/src/call/PeerConnectionClient.swift @@ -227,7 +227,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD return } guard let videoCaptureSession = self.videoCaptureSession else { - owsFail("\(self.TAG) videoCaptureSession was unexpectedly nil") + Logger.debug("\(self.TAG) videoCaptureSession was unexpectedly nil") return } From 43370ffc3fb1d18ba81d10da560d9424f49becfe Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 12 Sep 2017 17:14:43 -0400 Subject: [PATCH 2/3] Fix assert during calls without camera permission. // FREEBIE --- Signal/src/UIApplication+OWS.swift | 15 ++++++++++++++- Signal/src/call/CallService.swift | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Signal/src/UIApplication+OWS.swift b/Signal/src/UIApplication+OWS.swift index 11c5ad3a8..e7f66ff91 100644 --- a/Signal/src/UIApplication+OWS.swift +++ b/Signal/src/UIApplication+OWS.swift @@ -6,12 +6,25 @@ import Foundation extension UIApplication { + var frontmostViewControllerIgnoringAlerts: UIViewController? { + return findFrontmostViewController(ignoringAlerts:true) + } + var frontmostViewController: UIViewController? { + return findFrontmostViewController(ignoringAlerts:false) + } + + internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? { let window = UIApplication.shared.keyWindow var viewController = window!.rootViewController - + while true { if let nextViewController = viewController?.presentedViewController { + if ignoringAlerts { + if nextViewController as? UIAlertController != nil { + break + } + } viewController = nextViewController } else if let navigationController = viewController as? UINavigationController { if let nextViewController = navigationController.topViewController { diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 554caac9e..30202cc99 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -79,7 +79,7 @@ enum CallError: Error { } // Should be roughly synced with Android client for consistency -fileprivate let connectingTimeoutSeconds = 120 +private let connectingTimeoutSeconds = 120 // All Observer methods will be invoked from the main thread. protocol CallServiceObserver: class { @@ -1621,9 +1621,10 @@ protocol CallServiceObserver: class { return } - guard nil != UIApplication.shared.frontmostViewController as? CallViewController else { + let frontmostViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts + guard nil != frontmostViewController as? CallViewController else { OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file:#file, function:#function, line:#line) - owsFail("\(TAG) in \(#function) Call terminated due to call view presentation delay.") + owsFail("\(TAG) in \(#function) Call terminated due to call view presentation delay: \(frontmostViewController.debugDescription).") self.terminateCall() return } From 7b1b532b199b6ee6db271fd834c91cbf29ce9e16 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 18 Sep 2017 16:05:01 -0400 Subject: [PATCH 3/3] Respond to CR. // FREEBIE --- Signal/src/call/CallService.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 30202cc99..4d82d99e0 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -1622,7 +1622,8 @@ protocol CallServiceObserver: class { } let frontmostViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts - guard nil != frontmostViewController as? CallViewController else { + + guard nil != frontmostViewController as? CallViewController else { OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file:#file, function:#function, line:#line) owsFail("\(TAG) in \(#function) Call terminated due to call view presentation delay: \(frontmostViewController.debugDescription).") self.terminateCall()