Merge branch 'charlesmchen/callsVsPermissionsCrashes'

This commit is contained in:
Matthew Chen 2017-09-18 16:06:09 -04:00
commit f3fa107e47
3 changed files with 20 additions and 5 deletions

View file

@ -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 {

View file

@ -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,11 @@ 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
}

View file

@ -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
}