瀏覽代碼

fix(useVideoStream): error handling & add logs.

j8
Hristo Terezov 4 年之前
父節點
當前提交
f5a34183e9
共有 2 個檔案被更改,包括 62 行新增12 行删除
  1. 53
    11
      conference.js
  2. 9
    1
      modules/util/TaskQueue.js

+ 53
- 11
conference.js 查看文件

1020
                     // Rollback the video muted status by using null track
1020
                     // Rollback the video muted status by using null track
1021
                     return null;
1021
                     return null;
1022
                 })
1022
                 })
1023
-                .then(videoTrack => this.useVideoStream(videoTrack));
1023
+                .then(videoTrack => {
1024
+                    logger.debug(`muteVideo: calling useVideoStream for track: ${videoTrack}`);
1025
+
1026
+                    return this.useVideoStream(videoTrack);
1027
+                });
1024
         } else {
1028
         } else {
1025
             // FIXME show error dialog if it fails (should be handled by react)
1029
             // FIXME show error dialog if it fails (should be handled by react)
1026
             muteLocalVideo(mute);
1030
             muteLocalVideo(mute);
1343
             if (track.isAudioTrack()) {
1347
             if (track.isAudioTrack()) {
1344
                 return this.useAudioStream(track);
1348
                 return this.useAudioStream(track);
1345
             } else if (track.isVideoTrack()) {
1349
             } else if (track.isVideoTrack()) {
1350
+                logger.debug(`_setLocalAudioVideoStreams is calling useVideoStream with track: ${track}`);
1351
+
1346
                 return this.useVideoStream(track);
1352
                 return this.useVideoStream(track);
1347
             }
1353
             }
1354
+
1348
             logger.error(
1355
             logger.error(
1349
                     'Ignored not an audio nor a video track: ', track);
1356
                     'Ignored not an audio nor a video track: ', track);
1350
 
1357
 
1364
      * @returns {Promise}
1371
      * @returns {Promise}
1365
      */
1372
      */
1366
     useVideoStream(newTrack) {
1373
     useVideoStream(newTrack) {
1374
+        logger.debug(`useVideoStream: ${newTrack}`);
1375
+
1367
         return new Promise((resolve, reject) => {
1376
         return new Promise((resolve, reject) => {
1368
             _replaceLocalVideoTrackQueue.enqueue(onFinish => {
1377
             _replaceLocalVideoTrackQueue.enqueue(onFinish => {
1369
                 const state = APP.store.getState();
1378
                 const state = APP.store.getState();
1373
                 if (isPrejoinPageVisible(state)) {
1382
                 if (isPrejoinPageVisible(state)) {
1374
                     const oldTrack = getLocalJitsiVideoTrack(state);
1383
                     const oldTrack = getLocalJitsiVideoTrack(state);
1375
 
1384
 
1385
+                    logger.debug(`useVideoStream on the prejoin screen: Replacing ${oldTrack} with ${newTrack}`);
1386
+
1376
                     return APP.store.dispatch(replaceLocalTrack(oldTrack, newTrack))
1387
                     return APP.store.dispatch(replaceLocalTrack(oldTrack, newTrack))
1377
                         .then(resolve)
1388
                         .then(resolve)
1378
-                        .catch(reject)
1389
+                        .catch(error => {
1390
+                            logger.error(`useVideoStream failed on the prejoin screen: ${error}`);
1391
+                            reject(error);
1392
+                        })
1379
                         .then(onFinish);
1393
                         .then(onFinish);
1380
                 }
1394
                 }
1381
 
1395
 
1396
+                logger.debug(`useVideoStream: Replacing ${this.localVideo} with ${newTrack}`);
1382
                 APP.store.dispatch(
1397
                 APP.store.dispatch(
1383
-                replaceLocalTrack(this.localVideo, newTrack, room))
1398
+                    replaceLocalTrack(this.localVideo, newTrack, room))
1384
                     .then(() => {
1399
                     .then(() => {
1385
                         this.localVideo = newTrack;
1400
                         this.localVideo = newTrack;
1386
                         this._setSharingScreen(newTrack);
1401
                         this._setSharingScreen(newTrack);
1390
                         this.setVideoMuteStatus(this.isLocalVideoMuted());
1405
                         this.setVideoMuteStatus(this.isLocalVideoMuted());
1391
                     })
1406
                     })
1392
                     .then(resolve)
1407
                     .then(resolve)
1393
-                    .catch(reject)
1408
+                    .catch(error => {
1409
+                        logger.error(`useVideoStream failed: ${error}`);
1410
+                        reject(error);
1411
+                    })
1394
                     .then(onFinish);
1412
                     .then(onFinish);
1395
             });
1413
             });
1396
         });
1414
         });
1537
 
1555
 
1538
         if (didHaveVideo) {
1556
         if (didHaveVideo) {
1539
             promise = promise.then(() => createLocalTracksF({ devices: [ 'video' ] }))
1557
             promise = promise.then(() => createLocalTracksF({ devices: [ 'video' ] }))
1540
-                .then(([ stream ]) => this.useVideoStream(stream))
1558
+                .then(([ stream ]) => {
1559
+                    logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
1560
+
1561
+                    return this.useVideoStream(stream);
1562
+                })
1541
                 .catch(error => {
1563
                 .catch(error => {
1542
                     logger.error('failed to switch back to local video', error);
1564
                     logger.error('failed to switch back to local video', error);
1543
 
1565
 
1548
                     );
1570
                     );
1549
                 });
1571
                 });
1550
         } else {
1572
         } else {
1551
-            promise = promise.then(() => this.useVideoStream(null));
1573
+            promise = promise.then(() => {
1574
+                logger.debug('_turnScreenSharingOff using null for useVideoStream');
1575
+
1576
+                return this.useVideoStream(null);
1577
+            });
1552
         }
1578
         }
1553
 
1579
 
1554
         return promise.then(
1580
         return promise.then(
1559
             },
1585
             },
1560
             error => {
1586
             error => {
1561
                 this.videoSwitchInProgress = false;
1587
                 this.videoSwitchInProgress = false;
1588
+                logger.error(`_turnScreenSharingOff failed: ${error}`);
1589
+
1562
                 throw error;
1590
                 throw error;
1563
             });
1591
             });
1564
     },
1592
     },
1579
      * @return {Promise.<T>}
1607
      * @return {Promise.<T>}
1580
      */
1608
      */
1581
     async toggleScreenSharing(toggle = !this._untoggleScreenSharing, options = {}) {
1609
     async toggleScreenSharing(toggle = !this._untoggleScreenSharing, options = {}) {
1610
+        logger.debug(`toggleScreenSharing: ${toggle}`);
1582
         if (this.videoSwitchInProgress) {
1611
         if (this.videoSwitchInProgress) {
1583
             return Promise.reject('Switch in progress.');
1612
             return Promise.reject('Switch in progress.');
1584
         }
1613
         }
1645
                 desktopVideoStream.on(
1674
                 desktopVideoStream.on(
1646
                     JitsiTrackEvents.LOCAL_TRACK_STOPPED,
1675
                     JitsiTrackEvents.LOCAL_TRACK_STOPPED,
1647
                     () => {
1676
                     () => {
1677
+                        logger.debug(`Local screensharing track stopped. ${this.isSharingScreen}`);
1678
+
1648
                         // If the stream was stopped during screen sharing
1679
                         // If the stream was stopped during screen sharing
1649
                         // session then we should switch back to video.
1680
                         // session then we should switch back to video.
1650
                         this.isSharingScreen
1681
                         this.isSharingScreen
1809
                 const desktopVideoStream = streams.find(stream => stream.getType() === MEDIA_TYPE.VIDEO);
1840
                 const desktopVideoStream = streams.find(stream => stream.getType() === MEDIA_TYPE.VIDEO);
1810
 
1841
 
1811
                 if (desktopVideoStream) {
1842
                 if (desktopVideoStream) {
1843
+                    logger.debug(`_switchToScreenSharing is using ${desktopVideoStream} for useVideoStream`);
1812
                     await this.useVideoStream(desktopVideoStream);
1844
                     await this.useVideoStream(desktopVideoStream);
1813
                 }
1845
                 }
1814
 
1846
 
2014
             if (participantThatMutedUs) {
2046
             if (participantThatMutedUs) {
2015
                 APP.store.dispatch(participantMutedUs(participantThatMutedUs, track));
2047
                 APP.store.dispatch(participantMutedUs(participantThatMutedUs, track));
2016
                 if (this.isSharingScreen && track.isVideoTrack()) {
2048
                 if (this.isSharingScreen && track.isVideoTrack()) {
2049
+                    logger.debug('TRACK_MUTE_CHANGED while screen sharing');
2017
                     this._turnScreenSharingOff(false);
2050
                     this._turnScreenSharingOff(false);
2018
                 }
2051
                 }
2019
             }
2052
             }
2237
                         .then(effect => this.localVideo.setEffect(effect))
2270
                         .then(effect => this.localVideo.setEffect(effect))
2238
                         .then(() => {
2271
                         .then(() => {
2239
                             this.setVideoMuteStatus(false);
2272
                             this.setVideoMuteStatus(false);
2240
-                            logger.log('switched local video device');
2273
+                            logger.log('Switched local video device while screen sharing and the video is unmuted');
2241
                             this._updateVideoDeviceId();
2274
                             this._updateVideoDeviceId();
2242
                         })
2275
                         })
2243
                         .catch(err => APP.store.dispatch(notifyCameraError(err)));
2276
                         .catch(err => APP.store.dispatch(notifyCameraError(err)));
2246
                 // id for video, dispose the existing presenter track and create a new effect
2279
                 // id for video, dispose the existing presenter track and create a new effect
2247
                 // that can be applied on un-mute.
2280
                 // that can be applied on un-mute.
2248
                 } else if (this.isSharingScreen && videoWasMuted) {
2281
                 } else if (this.isSharingScreen && videoWasMuted) {
2249
-                    logger.log('switched local video device');
2282
+                    logger.log('Switched local video device: while screen sharing and the video is muted');
2250
                     const { height } = this.localVideo.track.getSettings();
2283
                     const { height } = this.localVideo.track.getSettings();
2251
 
2284
 
2252
                     this._updateVideoDeviceId();
2285
                     this._updateVideoDeviceId();
2273
 
2306
 
2274
                         return stream;
2307
                         return stream;
2275
                     })
2308
                     })
2276
-                    .then(stream => this.useVideoStream(stream))
2309
+                    .then(stream => {
2310
+                        logger.log('Switching the local video device.');
2311
+
2312
+                        return this.useVideoStream(stream);
2313
+                    })
2277
                     .then(() => {
2314
                     .then(() => {
2278
-                        logger.log('switched local video device');
2315
+                        logger.log('Switched local video device.');
2279
                         this._updateVideoDeviceId();
2316
                         this._updateVideoDeviceId();
2280
                     })
2317
                     })
2281
-                    .catch(err => APP.store.dispatch(notifyCameraError(err)));
2318
+                    .catch(error => {
2319
+                        logger.error(`Switching the local video device failed: ${error}`);
2320
+
2321
+                        return APP.store.dispatch(notifyCameraError(error));
2322
+                    });
2282
                 }
2323
                 }
2283
             }
2324
             }
2284
         );
2325
         );
2630
             delete newDevices.videoinput;
2671
             delete newDevices.videoinput;
2631
 
2672
 
2632
             // Removing the current video track in order to force the unmute to select the preferred device.
2673
             // Removing the current video track in order to force the unmute to select the preferred device.
2674
+            logger.debug('_onDeviceListChanged: Removing the current video track.');
2633
             this.useVideoStream(null);
2675
             this.useVideoStream(null);
2634
 
2676
 
2635
         }
2677
         }

+ 9
- 1
modules/util/TaskQueue.js 查看文件

46
         this._currentTask = this._queue.shift() || null;
46
         this._currentTask = this._queue.shift() || null;
47
 
47
 
48
         if (this._currentTask) {
48
         if (this._currentTask) {
49
-            this._currentTask(this._onTaskComplete);
49
+            logger.debug('Executing a task.');
50
+
51
+            try {
52
+                this._currentTask(this._onTaskComplete);
53
+            } catch (error) {
54
+                logger.error(`Task execution failed: ${error}`);
55
+                this._onTaskComplete();
56
+            }
50
         }
57
         }
51
     }
58
     }
52
 
59
 
58
      */
65
      */
59
     _onTaskComplete() {
66
     _onTaskComplete() {
60
         this._currentTask = null;
67
         this._currentTask = null;
68
+        logger.debug('Task completed.');
61
         this._executeNext();
69
         this._executeNext();
62
     }
70
     }
63
 }
71
 }

Loading…
取消
儲存