diff --git a/app/products/calls/alerts.ts b/app/products/calls/alerts.ts index feab1d6042..aac5a91c32 100644 --- a/app/products/calls/alerts.ts +++ b/app/products/calls/alerts.ts @@ -203,11 +203,7 @@ const doJoinCall = async ( } if (joinChannelIsDMorGM) { - // FIXME (MM-46048) - HACK - // There's a race condition between unmuting and receiving existing tracks from other participants. - // Fixing this properly requires extensive and potentially breaking changes. - // Waiting for a second before unmuting is a decent workaround that should work in most cases. - setTimeout(() => unmuteMyself(), 1000); + unmuteMyself(); } }; diff --git a/app/products/calls/rtcpeer/index.ts b/app/products/calls/rtcpeer/index.ts index 54c8c7e307..742023071b 100644 --- a/app/products/calls/rtcpeer/index.ts +++ b/app/products/calls/rtcpeer/index.ts @@ -25,16 +25,10 @@ export default class RTCPeer extends EventEmitter { private pc: RTCPeerConnection | null; private readonly senders: { [key: string]: RTCRtpSender }; private candidates: RTCIceCandidate[] = []; + private makingOffer = false; public connected: boolean; - private readonly sessionConstraints = { - mandatory: { - OfferToReceiveAudio: true, - OfferToReceiveVideo: true, - }, - }; - constructor(config: RTCPeerConfig) { super(); @@ -91,11 +85,13 @@ export default class RTCPeer extends EventEmitter { private async onNegotiationNeeded() { try { - const desc = await this.pc?.createOffer(this.sessionConstraints) as RTCSessionDescription; - await this.pc?.setLocalDescription(desc); + this.makingOffer = true; + await this.pc?.setLocalDescription(); this.emit('offer', this.pc?.localDescription); } catch (err) { this.emit('error', err); + } finally { + this.makingOffer = false; } } @@ -114,6 +110,10 @@ export default class RTCPeer extends EventEmitter { const msg = JSON.parse(data); + if (msg.type === 'offer' && (this.makingOffer || this.pc?.signalingState !== 'stable')) { + logDebug('signaling conflict, we are polite, proceeding...'); + } + try { switch (msg.type) { case 'candidate': @@ -131,7 +131,7 @@ export default class RTCPeer extends EventEmitter { break; case 'offer': await this.pc.setRemoteDescription(new RTCSessionDescription(msg)); - await this.pc.setLocalDescription(await this.pc.createAnswer() as RTCSessionDescription); + await this.pc.setLocalDescription(); this.emit('answer', this.pc.localDescription); break; case 'answer': diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c9c5d90d95..a32064b7a4 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -409,7 +409,7 @@ PODS: - react-native-video/Video (= 5.2.1) - react-native-video/Video (5.2.1): - React-Core - - react-native-webrtc (106.0.4): + - react-native-webrtc (106.0.5): - JitsiWebRTC (~> 106.0.0) - React-Core - react-native-webview (11.26.1): @@ -983,7 +983,7 @@ SPEC CHECKSUMS: react-native-safe-area-context: 39c2d8be3328df5d437ac1700f4f3a4f75716acc react-native-turbo-mailer: fa3f18b5a274fa32ebe43af125caf041f7cc4cbf react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253 - react-native-webrtc: 4522d420ead45fff83c4ecc7e5a706797857a185 + react-native-webrtc: ef315d8adb68e78298b22100377d12ef168efdb5 react-native-webview: 9f111dfbcfc826084d6c507f569e5e03342ee1c1 React-perflogger: c7ccda3d1d1da837f7ff4e54e816022a6803ee87 React-RCTActionSheet: 01c125aebbad462a24228f68c584c7a921d6c28e diff --git a/package-lock.json b/package-lock.json index 545be3790c..30e9785d17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,7 +92,7 @@ "react-native-vector-icons": "9.2.0", "react-native-video": "5.2.1", "react-native-walkthrough-tooltip": "1.5.0", - "react-native-webrtc": "106.0.4", + "react-native-webrtc": "106.0.5", "react-native-webview": "11.26.1", "react-syntax-highlighter": "15.5.0", "readable-stream": "3.6.0", @@ -18829,9 +18829,9 @@ } }, "node_modules/react-native-webrtc": { - "version": "106.0.4", - "resolved": "https://registry.npmjs.org/react-native-webrtc/-/react-native-webrtc-106.0.4.tgz", - "integrity": "sha512-mIdXstKkua5fRqPaCCxQuZmO7amVFnCUYibXP+cXLMSKIsHwilpvbMQRby0jcBftTGN6rjGyIr+CXffFrtztQg==", + "version": "106.0.5", + "resolved": "https://registry.npmjs.org/react-native-webrtc/-/react-native-webrtc-106.0.5.tgz", + "integrity": "sha512-EINzYpTZh6zXb2lcGH13Ieli1ur3M1FaT8R8WMqfUZEW8/y0WV6yBeQQVz55OA4LtWnBUX0RZyaYQ4aZN4e1Sw==", "hasInstallScript": true, "dependencies": { "adm-zip": "0.5.9", @@ -36143,9 +36143,9 @@ } }, "react-native-webrtc": { - "version": "106.0.4", - "resolved": "https://registry.npmjs.org/react-native-webrtc/-/react-native-webrtc-106.0.4.tgz", - "integrity": "sha512-mIdXstKkua5fRqPaCCxQuZmO7amVFnCUYibXP+cXLMSKIsHwilpvbMQRby0jcBftTGN6rjGyIr+CXffFrtztQg==", + "version": "106.0.5", + "resolved": "https://registry.npmjs.org/react-native-webrtc/-/react-native-webrtc-106.0.5.tgz", + "integrity": "sha512-EINzYpTZh6zXb2lcGH13Ieli1ur3M1FaT8R8WMqfUZEW8/y0WV6yBeQQVz55OA4LtWnBUX0RZyaYQ4aZN4e1Sw==", "requires": { "adm-zip": "0.5.9", "base64-js": "1.5.1", diff --git a/package.json b/package.json index 32257d2a4c..8709bbb325 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "react-native-vector-icons": "9.2.0", "react-native-video": "5.2.1", "react-native-walkthrough-tooltip": "1.5.0", - "react-native-webrtc": "106.0.4", + "react-native-webrtc": "106.0.5", "react-native-webview": "11.26.1", "react-syntax-highlighter": "15.5.0", "readable-stream": "3.6.0",