From 3ab65a2c88898bad8a6463943b50aad06d8dbd92 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 8 Feb 2017 15:49:17 -0500 Subject: [PATCH] Prevent CallKit timeout when placing outgoing call More fallout from the outbound call timeout which was causing all CallKit calls not promptly answered to show "Call Failed" Inserting the timeout exacerbated an existing issue: We can't wait for long before choosing to fulfill/fail an action without CallKit falling over and assuming the call failed. We don't actually need to consider the case where we "fail to initiate" the outgoing call. Instead we say it started "successfully, and if there is an error, the existing promise error handling will fail the call at that time. // FREEBIE --- .../src/call/Speakerbox/CallKitCallUIAdaptee.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift index 131b17971..1581012d9 100644 --- a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift +++ b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift @@ -228,14 +228,12 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { return } - self.callService.handleOutgoingCall(call).then { () -> Void in - action.fulfill() - self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil) - }.catch { error in - Logger.error("\(self.TAG) error \(error) in \(#function)") - self.callManager.removeCall(call) - action.fail() - } + // We can't wait for long before fulfilling the CXAction, else CallKit will show a "Failed Call". We don't + // actually need to wait for the outcome of the handleOutgoingCall promise, because it handles any errors by + // manually failing the call. + _ = self.callService.handleOutgoingCall(call) + action.fulfill() + self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil) } func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {