MM-49065 - Calls: Implement glare free negotiation (#7111)

* glare-free negotiation

* update to latest with fix

* remove unneeded sessionConstraints

* update to latest react-native-webrtc
This commit is contained in:
Christopher Poile
2023-02-13 11:03:49 -05:00
committed by GitHub
parent 35c98e673a
commit 4cb20a4bec
5 changed files with 21 additions and 25 deletions

View File

@@ -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();
}
};

View File

@@ -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':

View File

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

14
package-lock.json generated
View File

@@ -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",

View File

@@ -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",