Browse Source

fix(modificationQueue): error handling & logs

dev1
Hristo Terezov 4 years ago
parent
commit
0ec072378c

+ 2
- 1
JitsiConference.js View File

@@ -1127,7 +1127,8 @@ JitsiConference.prototype.replaceTrack = function(oldTrack, newTrack) {
1127 1127
             }
1128 1128
 
1129 1129
             return Promise.resolve();
1130
-        }, error => Promise.reject(new Error(error)));
1130
+        })
1131
+        .catch(error => Promise.reject(new Error(error)));
1131 1132
 };
1132 1133
 
1133 1134
 /**

+ 2
- 0
modules/RTC/TPCUtils.js View File

@@ -366,6 +366,8 @@ export class TPCUtils {
366 366
                 });
367 367
         }
368 368
 
369
+        logger.info('TPCUtils.replaceTrack called with no new track and no old track');
370
+
369 371
         return Promise.resolve();
370 372
     }
371 373
 

+ 4
- 0
modules/RTC/TraceablePeerConnection.js View File

@@ -1878,12 +1878,16 @@ TraceablePeerConnection.prototype.findSenderForTrack = function(track) {
1878 1878
  */
1879 1879
 TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
1880 1880
     if (browser.usesUnifiedPlan()) {
1881
+        logger.debug('TPC.replaceTrack using unified plan.');
1882
+
1881 1883
         return this.tpcUtils.replaceTrack(oldTrack, newTrack)
1882 1884
 
1883 1885
             // renegotiate when SDP is used for simulcast munging
1884 1886
             .then(() => this.isSimulcastOn() && browser.usesSdpMungingForSimulcast());
1885 1887
     }
1886 1888
 
1889
+    logger.debug('TPC.replaceTrack using plan B.');
1890
+
1887 1891
     let promiseChain = Promise.resolve();
1888 1892
 
1889 1893
     if (oldTrack) {

+ 11
- 1
modules/util/AsyncQueue.js View File

@@ -1,4 +1,9 @@
1
+/* global __filename */
2
+
1 3
 import async from 'async';
4
+import { getLogger } from 'jitsi-meet-logger';
5
+
6
+const logger = getLogger(__filename);
2 7
 
3 8
 /**
4 9
  * A queue for async task execution.
@@ -23,7 +28,12 @@ export default class AsyncQueue {
23 28
      * Internal task processing implementation which makes things work.
24 29
      */
25 30
     _processQueueTasks(task, finishedCallback) {
26
-        task(finishedCallback);
31
+        try {
32
+            task(finishedCallback);
33
+        } catch (error) {
34
+            logger.error(`Task failed: ${error}`);
35
+            finishedCallback(error);
36
+        }
27 37
     }
28 38
 
29 39
     /**

+ 70
- 14
modules/xmpp/JingleSessionPC.js View File

@@ -566,9 +566,9 @@ export default class JingleSessionPC extends JingleSession {
566 566
                     workFunction,
567 567
                     error => {
568 568
                         if (error) {
569
-                            logger.error('onnegotiationneeded error', error);
569
+                            logger.error(`onnegotiationneeded error on ${this}`, error);
570 570
                         } else {
571
-                            logger.debug('onnegotiationneeded executed - OK');
571
+                            logger.debug(`onnegotiationneeded executed - OK on ${this}`);
572 572
                         }
573 573
                     });
574 574
             }
@@ -811,6 +811,7 @@ export default class JingleSessionPC extends JingleSession {
811 811
             }
812 812
 
813 813
             finishedCallback();
814
+            logger.debug(`ICE candidates task finished on ${this}`);
814 815
         };
815 816
 
816 817
         logger.debug(
@@ -941,13 +942,14 @@ export default class JingleSessionPC extends JingleSession {
941 942
                 .then(() => finishedCallback(), error => finishedCallback(error));
942 943
         };
943 944
 
945
+        logger.debug(`Queued invite task on ${this}.`);
944 946
         this.modificationQueue.push(
945 947
             workFunction,
946 948
             error => {
947 949
                 if (error) {
948
-                    logger.error('invite error', error);
950
+                    logger.error(`invite error on ${this}`, error);
949 951
                 } else {
950
-                    logger.debug('invite executed - OK');
952
+                    logger.debug(`invite executed - OK on ${this}`);
951 953
                 }
952 954
             });
953 955
     }
@@ -1084,10 +1086,17 @@ export default class JingleSessionPC extends JingleSession {
1084 1086
                 .then(() => finishedCallback(), error => finishedCallback(error));
1085 1087
         };
1086 1088
 
1089
+        logger.debug(`Queued setOfferAnswerCycle task on ${this}`);
1087 1090
         this.modificationQueue.push(
1088 1091
             workFunction,
1089 1092
             error => {
1090
-                error ? failure(error) : success();
1093
+                if (error) {
1094
+                    logger.error(`setOfferAnswerCycle task on ${this} failed: ${error}`);
1095
+                    failure(error);
1096
+                } else {
1097
+                    logger.debug(`setOfferAnswerCycle task on ${this} done.`);
1098
+                    success();
1099
+                }
1091 1100
             });
1092 1101
     }
1093 1102
 
@@ -1107,9 +1116,20 @@ export default class JingleSessionPC extends JingleSession {
1107 1116
 
1108 1117
             // Initiate a renegotiate for the codec setting to take effect.
1109 1118
             const workFunction = finishedCallback => {
1110
-                this._renegotiate().then(() => finishedCallback(), error => finishedCallback(error));
1119
+                this._renegotiate().then(
1120
+                    () => {
1121
+                        logger.debug(`setVideoCodecs task on ${this} is done.`);
1122
+
1123
+                        return finishedCallback();
1124
+                    }, error => {
1125
+                        logger.error(`setVideoCodecs task on ${this} failed: ${error}`);
1126
+
1127
+                        return finishedCallback(error);
1128
+                    });
1111 1129
             };
1112 1130
 
1131
+            logger.debug(`Queued setVideoCodecs task on ${this}`);
1132
+
1113 1133
             // Queue and execute
1114 1134
             this.modificationQueue.push(workFunction);
1115 1135
         }
@@ -1700,6 +1720,8 @@ export default class JingleSessionPC extends JingleSession {
1700 1720
                 });
1701 1721
         };
1702 1722
 
1723
+        logger.debug(`Queued ${logPrefix} task on ${this}`);
1724
+
1703 1725
         // Queue and execute
1704 1726
         this.modificationQueue.push(workFunction);
1705 1727
     }
@@ -1891,6 +1913,8 @@ export default class JingleSessionPC extends JingleSession {
1891 1913
      */
1892 1914
     replaceTrack(oldTrack, newTrack) {
1893 1915
         const workFunction = finishedCallback => {
1916
+            logger.debug(`replaceTrack worker started. oldTrack = ${oldTrack}, newTrack = ${newTrack}, ${this}`);
1917
+
1894 1918
             const oldLocalSdp = this.peerconnection.localDescription.sdp;
1895 1919
 
1896 1920
             if (browser.usesPlanB()) {
@@ -1932,6 +1956,9 @@ export default class JingleSessionPC extends JingleSession {
1932 1956
                 .then(shouldRenegotiate => {
1933 1957
                     let promise = Promise.resolve();
1934 1958
 
1959
+                    logger.debug(`TPC.replaceTrack finished. shouldRenegotiate = ${
1960
+                        shouldRenegotiate}, JingleSessionState = ${this.state}, ${this}`);
1961
+
1935 1962
                     if (shouldRenegotiate
1936 1963
                         && (oldTrack || newTrack)
1937 1964
                         && this.state === JingleSessionState.ACTIVE) {
@@ -1944,13 +1971,23 @@ export default class JingleSessionPC extends JingleSession {
1944 1971
 
1945 1972
                     return promise.then(() => {
1946 1973
                         if (newTrack && newTrack.isVideoTrack()) {
1974
+                            logger.debug(`replaceTrack worker: setSenderVideoDegradationPreference(), ${this}`);
1975
+
1947 1976
                             // FIXME set all sender parameters in one go?
1948 1977
                             // Set the degradation preference on the new video sender.
1949 1978
                             return this.peerconnection.setSenderVideoDegradationPreference()
1950 1979
 
1951 1980
                                 // Apply the cached video constraints on the new video sender.
1952
-                                .then(() => this.peerconnection.setSenderVideoConstraint())
1953
-                                .then(() => this.peerconnection.setMaxBitRate());
1981
+                                .then(() => {
1982
+                                    logger.debug(`replaceTrack worker: setSenderVideoConstraint(), ${this}`);
1983
+
1984
+                                    return this.peerconnection.setSenderVideoConstraint();
1985
+                                })
1986
+                                .then(() => {
1987
+                                    logger.debug(`replaceTrack worker: setMaxBitRate(), ${this}`);
1988
+
1989
+                                    return this.peerconnection.setMaxBitRate();
1990
+                                });
1954 1991
                         }
1955 1992
                     });
1956 1993
                 })
@@ -1958,14 +1995,17 @@ export default class JingleSessionPC extends JingleSession {
1958 1995
         };
1959 1996
 
1960 1997
         return new Promise((resolve, reject) => {
1998
+            logger.debug(`Queued replaceTrack task. Old track = ${
1999
+                oldTrack}, new track = ${newTrack}, ${this}`);
2000
+
1961 2001
             this.modificationQueue.push(
1962 2002
                 workFunction,
1963 2003
                 error => {
1964 2004
                     if (error) {
1965
-                        logger.error('Replace track error:', error);
2005
+                        logger.error(`Replace track error on ${this}:`, error);
1966 2006
                         reject(error);
1967 2007
                     } else {
1968
-                        logger.info('Replace track done!');
2008
+                        logger.info(`Replace track done on ${this}!`);
1969 2009
                         resolve();
1970 2010
                     }
1971 2011
                 });
@@ -2167,13 +2207,21 @@ export default class JingleSessionPC extends JingleSession {
2167 2207
                 finishedCallback /* will be called with an error */);
2168 2208
         };
2169 2209
 
2210
+        logger.debug(`Queued _addRemoveTrackAsMuteUnmute task on ${this}. Operation - ${operationName}`);
2211
+
2170 2212
         return new Promise((resolve, reject) => {
2171 2213
             this.modificationQueue.push(
2172 2214
                 workFunction,
2173 2215
                 error => {
2174 2216
                     if (error) {
2217
+                        logger.error(`_addRemoveTrackAsMuteUnmute failed. Operation - ${
2218
+                            operationName}, peerconnection = ${this}`);
2219
+
2175 2220
                         reject(error);
2176 2221
                     } else {
2222
+                        logger.debug(`_addRemoveTrackAsMuteUnmute done. Operation - ${
2223
+                            operationName}, peerconnection = ${this}`);
2224
+
2177 2225
                         resolve();
2178 2226
                     }
2179 2227
                 });
@@ -2250,8 +2298,10 @@ export default class JingleSessionPC extends JingleSession {
2250 2298
                 workFunction,
2251 2299
                 error => {
2252 2300
                     if (error) {
2301
+                        logger.error(`Make ${logVideoStr}, ${logAudioStr} task failed!`);
2253 2302
                         reject(error);
2254 2303
                     } else {
2304
+                        logger.debug(`Make ${logVideoStr}, ${logAudioStr} task done!`);
2255 2305
                         resolve();
2256 2306
                     }
2257 2307
                 });
@@ -2302,15 +2352,15 @@ export default class JingleSessionPC extends JingleSession {
2302 2352
             }
2303 2353
         };
2304 2354
 
2305
-        logger.debug(
2306
-            `${this} queued "content-modify" task`
2307
-                + `(video senders="${newVideoSenders}")`);
2355
+        logger.debug(`${this} queued "content-modify" task(video senders="${newVideoSenders}")`);
2308 2356
 
2309 2357
         this.modificationQueue.push(
2310 2358
             workFunction,
2311 2359
             error => {
2312 2360
                 if (error) {
2313
-                    logger.error('"content-modify" failed', error);
2361
+                    logger.error(`"content-modify" failed on PC - ${this}`, error);
2362
+                } else {
2363
+                    logger.debug(`"content-modify" task(video senders="${newVideoSenders}") done. PC = ${this}`);
2314 2364
                 }
2315 2365
             });
2316 2366
     }
@@ -2500,9 +2550,12 @@ export default class JingleSessionPC extends JingleSession {
2500 2550
             this.peerconnection.onsignalingstatechange = null;
2501 2551
         }
2502 2552
 
2553
+        logger.debug(`Clearing modificationQueue on ${this}...`);
2554
+
2503 2555
         // Remove any pending tasks from the queue
2504 2556
         this.modificationQueue.clear();
2505 2557
 
2558
+        logger.debug(`Queued PC close task on ${this}...`);
2506 2559
         this.modificationQueue.push(finishCallback => {
2507 2560
             // The signaling layer will remove it's listeners
2508 2561
             this.signalingLayer.setChatRoom(null);
@@ -2510,8 +2563,11 @@ export default class JingleSessionPC extends JingleSession {
2510 2563
             // do not try to close if already closed.
2511 2564
             this.peerconnection && this.peerconnection.close();
2512 2565
             finishCallback();
2566
+            logger.debug(`PC close task on ${this} done!`);
2513 2567
         });
2514 2568
 
2569
+        logger.debug(`Shutdown modificationQueue on ${this}!`);
2570
+
2515 2571
         // No more tasks can go in after the close task
2516 2572
         this.modificationQueue.shutdown();
2517 2573
     }

Loading…
Cancel
Save