浏览代码

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 年前
父节点
当前提交
f6c94fffc4
共有 1 个文件被更改,包括 19 次插入13 次删除
  1. 19
    13
      conference.js

+ 19
- 13
conference.js 查看文件

@@ -1425,10 +1425,23 @@ export default {
1425 1425
 
1426 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 1443
         if (didHaveVideo) {
1431
-            promise = createLocalTracksF({ devices: [ 'video' ] })
1444
+            promise = promise.then(() => createLocalTracksF({ devices: [ 'video' ] }))
1432 1445
                 .then(([ stream ]) => this.useVideoStream(stream))
1433 1446
                 .then(() => {
1434 1447
                     sendAnalytics(createScreenSharingEvent('stopped'));
@@ -1444,17 +1457,7 @@ export default {
1444 1457
                     );
1445 1458
                 });
1446 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 1463
         return promise.then(
@@ -2179,6 +2182,7 @@ export default {
2179 2182
 
2180 2183
                     // dispose the existing presenter track and create a new
2181 2184
                     // camera track.
2185
+                    // FIXME JitsiLocalTrack.dispose is async and should be waited for
2182 2186
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2183 2187
                     this.localPresenterVideo = null;
2184 2188
 
@@ -2199,6 +2203,8 @@ export default {
2199 2203
                     const { height } = this.localVideo.track.getSettings();
2200 2204
 
2201 2205
                     this._updateVideoDeviceId();
2206
+
2207
+                    // FIXME JitsiLocalTrack.dispose is async and should be waited for
2202 2208
                     this.localPresenterVideo && this.localPresenterVideo.dispose();
2203 2209
                     this.localPresenterVideo = null;
2204 2210
                     this._createPresenterStreamEffect(height, cameraDeviceId);

正在加载...
取消
保存