Fixes #3134 - Fix answering call not opening app
- we're currently working around the widget not properly aquiring media streams by manually terminating a call before starting the web view - it seems that there's a race condition between that and the system opening the app - as such we need to delay terminating the call until the system gets a chance to handle the redirect
This commit is contained in:
committed by
Stefan Ceriu
parent
278e0a23dd
commit
e5b4287940
@@ -192,28 +192,36 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||
if let incomingCallID {
|
||||
// Fixes broken videos on EC web when a CallKit session is established.
|
||||
//
|
||||
// Reporting an ongoing call through `reportNewIncomingCall` + `CXAnswerCallAction`
|
||||
// or `reportOutgoingCall:connectedAt:` will give exclusive access for media to the
|
||||
// ongoing process, which is different than the WKWebKit is running on, making EC
|
||||
// unable to aquire media streams.
|
||||
// Reporting the call as ended imediately after answering it works around that
|
||||
// as EC gets access to media again and EX builds the right UI in `setupCallSession`
|
||||
//
|
||||
// https://github.com/element-hq/element-x-ios/issues/3041
|
||||
// https://forums.developer.apple.com/forums/thread/685268
|
||||
// https://stackoverflow.com/questions/71483732/webrtc-running-from-wkwebview-avaudiosession-development-roadblock
|
||||
provider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .answeredElsewhere)
|
||||
|
||||
actionsSubject.send(.startCall(roomID: incomingCallID.roomID))
|
||||
endUnansweredCallTask?.cancel()
|
||||
} else {
|
||||
guard let incomingCallID else {
|
||||
MXLog.error("Failed answering incoming call, missing incomingCallID")
|
||||
return
|
||||
}
|
||||
|
||||
// Fixes broken videos on EC web when a CallKit session is established.
|
||||
//
|
||||
// Reporting an ongoing call through `reportNewIncomingCall` + `CXAnswerCallAction`
|
||||
// or `reportOutgoingCall:connectedAt:` will give exclusive access for media to the
|
||||
// ongoing process, which is different than the WKWebKit is running on, making EC
|
||||
// unable to aquire media streams.
|
||||
// Reporting the call as ended imediately after answering it works around that
|
||||
// as EC gets access to media again and EX builds the right UI in `setupCallSession`
|
||||
//
|
||||
// https://github.com/element-hq/element-x-ios/issues/3041
|
||||
// https://forums.developer.apple.com/forums/thread/685268
|
||||
// https://stackoverflow.com/questions/71483732/webrtc-running-from-wkwebview-avaudiosession-development-roadblock
|
||||
|
||||
// First fullfill the action
|
||||
action.fulfill()
|
||||
|
||||
// And delay ending the call so that the app has enough time
|
||||
// to get deeplinked into
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
// Then end the and call rely on `setupCallSession` to create a new one
|
||||
provider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .remoteEnded)
|
||||
|
||||
self.actionsSubject.send(.startCall(roomID: incomingCallID.roomID))
|
||||
self.endUnansweredCallTask?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
|
||||
|
||||
Reference in New Issue
Block a user