Browse Source

fix(modificationQueue): error handling & logs

dev1
Hristo Terezov 4 years ago
parent
commit
0ec072378c

+ 2
- 1
JitsiConference.js View File

1127
             }
1127
             }
1128
 
1128
 
1129
             return Promise.resolve();
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
                 });
366
                 });
367
         }
367
         }
368
 
368
 
369
+        logger.info('TPCUtils.replaceTrack called with no new track and no old track');
370
+
369
         return Promise.resolve();
371
         return Promise.resolve();
370
     }
372
     }
371
 
373
 

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

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

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

1
+/* global __filename */
2
+
1
 import async from 'async';
3
 import async from 'async';
4
+import { getLogger } from 'jitsi-meet-logger';
5
+
6
+const logger = getLogger(__filename);
2
 
7
 
3
 /**
8
 /**
4
  * A queue for async task execution.
9
  * A queue for async task execution.
23
      * Internal task processing implementation which makes things work.
28
      * Internal task processing implementation which makes things work.
24
      */
29
      */
25
     _processQueueTasks(task, finishedCallback) {
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
                     workFunction,
566
                     workFunction,
567
                     error => {
567
                     error => {
568
                         if (error) {
568
                         if (error) {
569
-                            logger.error('onnegotiationneeded error', error);
569
+                            logger.error(`onnegotiationneeded error on ${this}`, error);
570
                         } else {
570
                         } else {
571
-                            logger.debug('onnegotiationneeded executed - OK');
571
+                            logger.debug(`onnegotiationneeded executed - OK on ${this}`);
572
                         }
572
                         }
573
                     });
573
                     });
574
             }
574
             }
811
             }
811
             }
812
 
812
 
813
             finishedCallback();
813
             finishedCallback();
814
+            logger.debug(`ICE candidates task finished on ${this}`);
814
         };
815
         };
815
 
816
 
816
         logger.debug(
817
         logger.debug(
941
                 .then(() => finishedCallback(), error => finishedCallback(error));
942
                 .then(() => finishedCallback(), error => finishedCallback(error));
942
         };
943
         };
943
 
944
 
945
+        logger.debug(`Queued invite task on ${this}.`);
944
         this.modificationQueue.push(
946
         this.modificationQueue.push(
945
             workFunction,
947
             workFunction,
946
             error => {
948
             error => {
947
                 if (error) {
949
                 if (error) {
948
-                    logger.error('invite error', error);
950
+                    logger.error(`invite error on ${this}`, error);
949
                 } else {
951
                 } else {
950
-                    logger.debug('invite executed - OK');
952
+                    logger.debug(`invite executed - OK on ${this}`);
951
                 }
953
                 }
952
             });
954
             });
953
     }
955
     }
1084
                 .then(() => finishedCallback(), error => finishedCallback(error));
1086
                 .then(() => finishedCallback(), error => finishedCallback(error));
1085
         };
1087
         };
1086
 
1088
 
1089
+        logger.debug(`Queued setOfferAnswerCycle task on ${this}`);
1087
         this.modificationQueue.push(
1090
         this.modificationQueue.push(
1088
             workFunction,
1091
             workFunction,
1089
             error => {
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
 
1116
 
1108
             // Initiate a renegotiate for the codec setting to take effect.
1117
             // Initiate a renegotiate for the codec setting to take effect.
1109
             const workFunction = finishedCallback => {
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
             // Queue and execute
1133
             // Queue and execute
1114
             this.modificationQueue.push(workFunction);
1134
             this.modificationQueue.push(workFunction);
1115
         }
1135
         }
1700
                 });
1720
                 });
1701
         };
1721
         };
1702
 
1722
 
1723
+        logger.debug(`Queued ${logPrefix} task on ${this}`);
1724
+
1703
         // Queue and execute
1725
         // Queue and execute
1704
         this.modificationQueue.push(workFunction);
1726
         this.modificationQueue.push(workFunction);
1705
     }
1727
     }
1891
      */
1913
      */
1892
     replaceTrack(oldTrack, newTrack) {
1914
     replaceTrack(oldTrack, newTrack) {
1893
         const workFunction = finishedCallback => {
1915
         const workFunction = finishedCallback => {
1916
+            logger.debug(`replaceTrack worker started. oldTrack = ${oldTrack}, newTrack = ${newTrack}, ${this}`);
1917
+
1894
             const oldLocalSdp = this.peerconnection.localDescription.sdp;
1918
             const oldLocalSdp = this.peerconnection.localDescription.sdp;
1895
 
1919
 
1896
             if (browser.usesPlanB()) {
1920
             if (browser.usesPlanB()) {
1932
                 .then(shouldRenegotiate => {
1956
                 .then(shouldRenegotiate => {
1933
                     let promise = Promise.resolve();
1957
                     let promise = Promise.resolve();
1934
 
1958
 
1959
+                    logger.debug(`TPC.replaceTrack finished. shouldRenegotiate = ${
1960
+                        shouldRenegotiate}, JingleSessionState = ${this.state}, ${this}`);
1961
+
1935
                     if (shouldRenegotiate
1962
                     if (shouldRenegotiate
1936
                         && (oldTrack || newTrack)
1963
                         && (oldTrack || newTrack)
1937
                         && this.state === JingleSessionState.ACTIVE) {
1964
                         && this.state === JingleSessionState.ACTIVE) {
1944
 
1971
 
1945
                     return promise.then(() => {
1972
                     return promise.then(() => {
1946
                         if (newTrack && newTrack.isVideoTrack()) {
1973
                         if (newTrack && newTrack.isVideoTrack()) {
1974
+                            logger.debug(`replaceTrack worker: setSenderVideoDegradationPreference(), ${this}`);
1975
+
1947
                             // FIXME set all sender parameters in one go?
1976
                             // FIXME set all sender parameters in one go?
1948
                             // Set the degradation preference on the new video sender.
1977
                             // Set the degradation preference on the new video sender.
1949
                             return this.peerconnection.setSenderVideoDegradationPreference()
1978
                             return this.peerconnection.setSenderVideoDegradationPreference()
1950
 
1979
 
1951
                                 // Apply the cached video constraints on the new video sender.
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
         };
1995
         };
1959
 
1996
 
1960
         return new Promise((resolve, reject) => {
1997
         return new Promise((resolve, reject) => {
1998
+            logger.debug(`Queued replaceTrack task. Old track = ${
1999
+                oldTrack}, new track = ${newTrack}, ${this}`);
2000
+
1961
             this.modificationQueue.push(
2001
             this.modificationQueue.push(
1962
                 workFunction,
2002
                 workFunction,
1963
                 error => {
2003
                 error => {
1964
                     if (error) {
2004
                     if (error) {
1965
-                        logger.error('Replace track error:', error);
2005
+                        logger.error(`Replace track error on ${this}:`, error);
1966
                         reject(error);
2006
                         reject(error);
1967
                     } else {
2007
                     } else {
1968
-                        logger.info('Replace track done!');
2008
+                        logger.info(`Replace track done on ${this}!`);
1969
                         resolve();
2009
                         resolve();
1970
                     }
2010
                     }
1971
                 });
2011
                 });
2167
                 finishedCallback /* will be called with an error */);
2207
                 finishedCallback /* will be called with an error */);
2168
         };
2208
         };
2169
 
2209
 
2210
+        logger.debug(`Queued _addRemoveTrackAsMuteUnmute task on ${this}. Operation - ${operationName}`);
2211
+
2170
         return new Promise((resolve, reject) => {
2212
         return new Promise((resolve, reject) => {
2171
             this.modificationQueue.push(
2213
             this.modificationQueue.push(
2172
                 workFunction,
2214
                 workFunction,
2173
                 error => {
2215
                 error => {
2174
                     if (error) {
2216
                     if (error) {
2217
+                        logger.error(`_addRemoveTrackAsMuteUnmute failed. Operation - ${
2218
+                            operationName}, peerconnection = ${this}`);
2219
+
2175
                         reject(error);
2220
                         reject(error);
2176
                     } else {
2221
                     } else {
2222
+                        logger.debug(`_addRemoveTrackAsMuteUnmute done. Operation - ${
2223
+                            operationName}, peerconnection = ${this}`);
2224
+
2177
                         resolve();
2225
                         resolve();
2178
                     }
2226
                     }
2179
                 });
2227
                 });
2250
                 workFunction,
2298
                 workFunction,
2251
                 error => {
2299
                 error => {
2252
                     if (error) {
2300
                     if (error) {
2301
+                        logger.error(`Make ${logVideoStr}, ${logAudioStr} task failed!`);
2253
                         reject(error);
2302
                         reject(error);
2254
                     } else {
2303
                     } else {
2304
+                        logger.debug(`Make ${logVideoStr}, ${logAudioStr} task done!`);
2255
                         resolve();
2305
                         resolve();
2256
                     }
2306
                     }
2257
                 });
2307
                 });
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
         this.modificationQueue.push(
2357
         this.modificationQueue.push(
2310
             workFunction,
2358
             workFunction,
2311
             error => {
2359
             error => {
2312
                 if (error) {
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
             this.peerconnection.onsignalingstatechange = null;
2550
             this.peerconnection.onsignalingstatechange = null;
2501
         }
2551
         }
2502
 
2552
 
2553
+        logger.debug(`Clearing modificationQueue on ${this}...`);
2554
+
2503
         // Remove any pending tasks from the queue
2555
         // Remove any pending tasks from the queue
2504
         this.modificationQueue.clear();
2556
         this.modificationQueue.clear();
2505
 
2557
 
2558
+        logger.debug(`Queued PC close task on ${this}...`);
2506
         this.modificationQueue.push(finishCallback => {
2559
         this.modificationQueue.push(finishCallback => {
2507
             // The signaling layer will remove it's listeners
2560
             // The signaling layer will remove it's listeners
2508
             this.signalingLayer.setChatRoom(null);
2561
             this.signalingLayer.setChatRoom(null);
2510
             // do not try to close if already closed.
2563
             // do not try to close if already closed.
2511
             this.peerconnection && this.peerconnection.close();
2564
             this.peerconnection && this.peerconnection.close();
2512
             finishCallback();
2565
             finishCallback();
2566
+            logger.debug(`PC close task on ${this} done!`);
2513
         });
2567
         });
2514
 
2568
 
2569
+        logger.debug(`Shutdown modificationQueue on ${this}!`);
2570
+
2515
         // No more tasks can go in after the close task
2571
         // No more tasks can go in after the close task
2516
         this.modificationQueue.shutdown();
2572
         this.modificationQueue.shutdown();
2517
     }
2573
     }

Loading…
Cancel
Save