Browse Source

fix(useVideoStream): error handling & add logs.

master
Hristo Terezov 4 years ago
parent
commit
f5a34183e9
2 changed files with 62 additions and 12 deletions
  1. 53
    11
      conference.js
  2. 9
    1
      modules/util/TaskQueue.js

+ 53
- 11
conference.js View File

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

+ 9
- 1
modules/util/TaskQueue.js View File

@@ -46,7 +46,14 @@ export class TaskQueue {
46 46
         this._currentTask = this._queue.shift() || null;
47 47
 
48 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,6 +65,7 @@ export class TaskQueue {
58 65
      */
59 66
     _onTaskComplete() {
60 67
         this._currentTask = null;
68
+        logger.debug('Task completed.');
61 69
         this._executeNext();
62 70
     }
63 71
 }

Loading…
Cancel
Save