Sfoglia il codice sorgente

fix(conference.js): prevent presenter track leak

A duct tape fix for presenter track leak for a case when presenter GUM
is in progress when screensharing is being turned off.
master
paweldomas 5 anni fa
parent
commit
f6c94fffc4
1 ha cambiato i file con 19 aggiunte e 13 eliminazioni
  1. 19
    13
      conference.js

+ 19
- 13
conference.js Vedi File

1425
 
1425
 
1426
         this._stopProxyConnection();
1426
         this._stopProxyConnection();
1427
 
1427
 
1428
-        let promise = null;
1428
+        // It can happen that presenter GUM is in progress while screensharing is being turned off. Here it needs to
1429
+        // wait for that GUM to be resolved in order to prevent leaking the presenter track(this.localPresenterVideo
1430
+        // will be null when SS is being turned off, but it will initialize once GUM resolves).
1431
+        let promise = _prevMutePresenterVideo = _prevMutePresenterVideo.then(() => {
1432
+            // mute the presenter track if it exists.
1433
+            if (this.localPresenterVideo) {
1434
+                APP.store.dispatch(setVideoMuted(true, MEDIA_TYPE.PRESENTER));
1435
+
1436
+                return this.localPresenterVideo.dispose().then(() => {
1437
+                    APP.store.dispatch(trackRemoved(this.localPresenterVideo));
1438
+                    this.localPresenterVideo = null;
1439
+                });
1440
+            }
1441
+        });
1429
 
1442
 
1430
         if (didHaveVideo) {
1443
         if (didHaveVideo) {
1431
-            promise = createLocalTracksF({ devices: [ 'video' ] })
1444
+            promise = promise.then(() => createLocalTracksF({ devices: [ 'video' ] }))
1432
                 .then(([ stream ]) => this.useVideoStream(stream))
1445
                 .then(([ stream ]) => this.useVideoStream(stream))
1433
                 .then(() => {
1446
                 .then(() => {
1434
                     sendAnalytics(createScreenSharingEvent('stopped'));
1447
                     sendAnalytics(createScreenSharingEvent('stopped'));
1444
                     );
1457
                     );
1445
                 });
1458
                 });
1446
         } else {
1459
         } else {
1447
-            promise = this.useVideoStream(null);
1448
-        }
1449
-
1450
-        // mute the presenter track if it exists.
1451
-        if (this.localPresenterVideo) {
1452
-            APP.store.dispatch(
1453
-                setVideoMuted(true, MEDIA_TYPE.PRESENTER));
1454
-            this.localPresenterVideo.dispose();
1455
-            APP.store.dispatch(
1456
-                trackRemoved(this.localPresenterVideo));
1457
-            this.localPresenterVideo = null;
1460
+            promise = promise.then(() => this.useVideoStream(null));
1458
         }
1461
         }
1459
 
1462
 
1460
         return promise.then(
1463
         return promise.then(
2179
 
2182
 
2180
                     // dispose the existing presenter track and create a new
2183
                     // dispose the existing presenter track and create a new
2181
                     // camera track.
2184
                     // camera track.
2185
+                    // FIXME JitsiLocalTrack.dispose is async and should be waited for
2182
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2186
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2183
                     this.localPresenterVideo = null;
2187
                     this.localPresenterVideo = null;
2184
 
2188
 
2199
                     const { height } = this.localVideo.track.getSettings();
2203
                     const { height } = this.localVideo.track.getSettings();
2200
 
2204
 
2201
                     this._updateVideoDeviceId();
2205
                     this._updateVideoDeviceId();
2206
+
2207
+                    // FIXME JitsiLocalTrack.dispose is async and should be waited for
2202
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2208
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2203
                     this.localPresenterVideo = null;
2209
                     this.localPresenterVideo = null;
2204
                     this._createPresenterStreamEffect(height, cameraDeviceId);
2210
                     this._createPresenterStreamEffect(height, cameraDeviceId);

Loading…
Annulla
Salva