Ver código fonte

Workaround for Chrome ice connection failure detection (#1685)

* fix: re-enable that ICE connection failures in Chrome are detected
* fixed linting errors
dev1
Nils Ohlmeier 4 anos atrás
pai
commit
d4bb376f96
Nenhuma conta vinculada ao e-mail do autor do commit

+ 10
- 0
modules/RTC/TraceablePeerConnection.js Ver arquivo

@@ -355,6 +355,13 @@ export default function TraceablePeerConnection(
355 355
             this.onnegotiationneeded(event);
356 356
         }
357 357
     };
358
+    this.onconnectionstatechange = null;
359
+    this.peerconnection.onconnectionstatechange = event => {
360
+        this.trace('onconnectionstatechange', this.connectionState);
361
+        if (this.onconnectionstatechange !== null) {
362
+            this.onconnectionstatechange(event);
363
+        }
364
+    };
358 365
     this.ondatachannel = null;
359 366
     this.peerconnection.ondatachannel = event => {
360 367
         this.trace('ondatachannel');
@@ -1496,6 +1503,9 @@ const getters = {
1496 1503
     iceConnectionState() {
1497 1504
         return this.peerconnection.iceConnectionState;
1498 1505
     },
1506
+    connectionState() {
1507
+        return this.peerconnection.connectionState;
1508
+    },
1499 1509
     localDescription() {
1500 1510
         let desc = this.peerconnection.localDescription;
1501 1511
 

+ 22
- 0
modules/xmpp/JingleSessionPC.js Ver arquivo

@@ -559,6 +559,28 @@ export default class JingleSessionPC extends JingleSession {
559 559
             }
560 560
         };
561 561
 
562
+
563
+        /**
564
+         * The connection state event is fired whenever the aggregate of underlying
565
+         * transports change their state.
566
+         */
567
+        this.peerconnection.onconnectionstatechange = () => {
568
+            const icestate = this.peerconnection.iceConnectionState;
569
+
570
+            switch (this.peerconnection.connectionState) {
571
+            case 'failed':
572
+                // Since version 76 Chrome no longer switches ICE connection
573
+                // state to failed (see
574
+                // https://bugs.chromium.org/p/chromium/issues/detail?id=982793
575
+                // for details) we use this workaround to recover from lost connections
576
+                if (icestate === 'disconnected') {
577
+                    this.room.eventEmitter.emit(
578
+                        XMPPEvents.CONNECTION_ICE_FAILED, this);
579
+                }
580
+                break;
581
+            }
582
+        };
583
+
562 584
         /**
563 585
          * The negotiationneeded event is fired whenever we shake the media on the
564 586
          * RTCPeerConnection object.

Carregando…
Cancelar
Salvar