diff --git a/Podfile b/Podfile index a095f7f57..b934649d5 100644 --- a/Podfile +++ b/Podfile @@ -5,8 +5,7 @@ target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' #pod 'AxolotlKit', path: '../SignalProtocolKit' - #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'mkirk/webrtc' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'charlesmchen/webrtc/threadSafety' + pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'mkirk/webrtc' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'PastelogKit', '~> 1.3' diff --git a/Podfile.lock b/Podfile.lock index 8cd84ef2d..6bd95ac67 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -123,7 +123,7 @@ DEPENDENCIES: - PastelogKit (~> 1.3) - PureLayout - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `charlesmchen/webrtc/threadSafety`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `mkirk/webrtc`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) - ZXingObjC @@ -131,7 +131,7 @@ EXTERNAL SOURCES: AxolotlKit: :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :branch: charlesmchen/webrtc/threadSafety + :branch: mkirk/webrtc :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -141,7 +141,7 @@ CHECKOUT OPTIONS: :commit: 919d541d6b8a8802a94f943026b8f68394e2c0b8 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: ddbc4819f1aa10e0164c1591dfc12cba49e04ed0 + :commit: 7ca1d5e8a62273b524281d905c560b08c7c22039 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 41b57bb2fc292a814f758441a05243eb38457027 @@ -173,6 +173,6 @@ SPEC CHECKSUMS: YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a -PODFILE CHECKSUM: beb37f2fe7d11b6d2a8124b03b20f903908fd8aa +PODFILE CHECKSUM: 9f2e2cf6d4db276e3d0280343260503d09c72979 COCOAPODS: 1.0.1 diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 2345f8a9a..2e3ed4663 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -635,11 +635,7 @@ protocol CallServiceObserver: class { callRecord.save() let message = DataChannelMessage.forConnected(callId: call.signalingId) - peerConnectionClient.sendDataChannelMessage(data: message.asData()).then { _ in - Logger.debug("\(self.TAG) sendDataChannelMessage succeeded") - }.catch(on: DispatchQueue.main) { _ in - Logger.warn("\(self.TAG) sendDataChannelMessage failed") - } + peerConnectionClient.sendDataChannelMessage(data: message.asData()) handleConnectedCall(call) } @@ -737,11 +733,7 @@ protocol CallServiceObserver: class { // If the call is connected, we can send the hangup via the data channel. let message = DataChannelMessage.forHangup(callId: call.signalingId) - peerConnectionClient.sendDataChannelMessage(data: message.asData()).then { _ in - Logger.debug("\(self.TAG) sendDataChannelMessage succeeded") - }.catch(on: DispatchQueue.main) { _ in - Logger.warn("\(self.TAG) sendDataChannelMessage failed") - } + peerConnectionClient.sendDataChannelMessage(data: message.asData()) // If the call hasn't started yet, we don't have a data channel to communicate the hang up. Use Signal Service Message. let hangupMessage = OWSCallHangupMessage(callId: call.signalingId) @@ -1075,11 +1067,7 @@ protocol CallServiceObserver: class { self.peerConnectionClient?.setLocalVideoEnabled(enabled: shouldHaveLocalVideoTrack) let message = DataChannelMessage.forVideoStreamingStatus(callId: call.signalingId, enabled:shouldHaveLocalVideoTrack) - peerConnectionClient.sendDataChannelMessage(data: message.asData()).then { _ in - Logger.debug("\(self.TAG) sendDataChannelMessage succeeded") - }.catch(on: DispatchQueue.main) { _ in - Logger.warn("\(self.TAG) sendDataChannelMessage failed") - } + peerConnectionClient.sendDataChannelMessage(data: message.asData()) } // MARK: - Observers diff --git a/Signal/src/call/PeerConnectionClient.swift b/Signal/src/call/PeerConnectionClient.swift index e5852806e..3ff27d3d7 100644 --- a/Signal/src/call/PeerConnectionClient.swift +++ b/Signal/src/call/PeerConnectionClient.swift @@ -18,6 +18,8 @@ let kMediaConstraintsMaxHeight = kRTCMediaConstraintsMaxHeight /** * The PeerConnectionClient notifies it's delegate (the CallService) of key events in the call signaling life cycle + * + * The delegate's methods will always be called on the main thread. */ protocol PeerConnectionClientDelegate: class { @@ -143,7 +145,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD public func createSignalingDataChannel() { AssertIsOnMainThread() - + PeerConnectionClient.signalingQueue.sync { let dataChannel = peerConnection.dataChannel(forLabel: Identifiers.dataChannelSignaling.rawValue, configuration: RTCDataChannelConfiguration()) @@ -404,24 +406,24 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD // MARK: - Data Channel - public func sendDataChannelMessage(data: Data) -> Promise { + public func sendDataChannelMessage(data: Data) { AssertIsOnMainThread() - - return Promise { fulfill, reject in - AssertIsOnMainThread() - - PeerConnectionClient.signalingQueue.async { - self.assertOnSignalingQueue() - guard let dataChannel = self.dataChannel else { - Logger.error("\(self.TAG) in \(#function) ignoring sending \(data) for nil dataChannel") - reject(OWSErrorMakeWebRTCMissingDataChannelError()) - return - } - - let buffer = RTCDataBuffer(data: data, isBinary: false) - let result = dataChannel.sendData(buffer) - fulfill(result) + PeerConnectionClient.signalingQueue.async { + self.assertOnSignalingQueue() + + guard let dataChannel = self.dataChannel else { + Logger.error("\(self.TAG) in \(#function) ignoring sending \(data) for nil dataChannel") + return + } + + let buffer = RTCDataBuffer(data: data, isBinary: false) + let result = dataChannel.sendData(buffer) + + if result { + Logger.debug("\(self.TAG) sendDataChannelMessage succeeded") + } else { + Logger.warn("\(self.TAG) sendDataChannelMessage failed") } } } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 7618241da..f5bd472fc 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -250,9 +250,6 @@ /* Error message when attempting to send message */ "ERROR_DESCRIPTION_UNREGISTERED_RECIPIENT" = "Recipient is no longer a Signal user."; -/* Missing data channel while trying to sending message */ -"ERROR_DESCRIPTION_WEBRTC_MISSING_DATA_CHANNEL" = "Missing connection"; - /* No comment provided by engineer. */ "ERROR_MESSAGE_DUPLICATE_MESSAGE" = "Received a duplicated message.";