|
1 | 1 | # webrtc-issue-detector |
2 | | -WebRTC diagnostic tool that detects issues with network or user devices |
3 | 2 |
|
4 | | ----- |
| 3 | +Diagnostic tool for WebRTC applications that analyzes WebRTC getStats() result in realtime and generates a report on possible issues. |
| 4 | + |
| 5 | + |
| 6 | +## Key features |
| 7 | + |
| 8 | +- **Mean opinion score** - calculates [MOS](https://en.wikipedia.org/wiki/Mean_opinion_score) for inbound and outbound network connections that can indicate problems before it even appears. |
| 9 | +- **CPU issues** - indicates possible issues with encoding and decoding media streams. |
| 10 | +- **Server issues** - indicates possible server side issues. |
| 11 | +- **Fully customizable** - allows to create your own detectors or WebRTC getStats() parsers. |
| 12 | + |
5 | 13 |
|
6 | 14 | ## Installation |
7 | 15 | `yarn add webrtc-issue-detector` |
8 | 16 |
|
9 | 17 |
|
10 | 18 | ## Usage |
11 | | -### Import |
| 19 | + |
| 20 | +### Getting started |
12 | 21 | ```typescript |
13 | 22 | import WebRTCIssueDetector from 'webrtc-issue-detector'; |
14 | 23 |
|
15 | | -return new WebRTCIssueDetector({ |
16 | | - onIssues: (issues) => console.log('Issues detected:', issues), |
17 | | - onNetworkScoresUpdated: (scores) => console.log('Network scores updated:', scores), |
| 24 | +// create it before the first instance of RTCPeerConnection is created |
| 25 | +const webRtcIssueDetector = new WebRTCIssueDetector({ |
| 26 | + onIssues: (issues) => issues.map((issue) => { |
| 27 | + console.log('Issues type:', issue.type); // eg. "network" |
| 28 | + console.log('Issues reason:', issue.reason); // eg. "outbound-network-throughput" |
| 29 | + console.log('Issues reason:', issue.debug); // eg. "packetLoss: 12%, jitter: 230, rtt: 150" |
| 30 | + }), |
| 31 | + onNetworkScoresUpdated: (scores) => { |
| 32 | + console.log('Inbound network score', scores.inbound); // eg. 3.7 |
| 33 | + console.log('Outbound network score', scores.outbound); // eg. 4.5 |
| 34 | + } |
18 | 35 | }); |
| 36 | + |
| 37 | +// start collecting getStats() and detecting issues |
| 38 | +webRtcIssueDetector.watchNewPeerConnections(); |
19 | 39 | ``` |
20 | 40 |
|
21 | 41 | ### Configure |
@@ -61,6 +81,118 @@ new WebRTCIssueDetector({ |
61 | 81 | }); |
62 | 82 | ``` |
63 | 83 |
|
| 84 | +## Detectors |
| 85 | + |
| 86 | +### AvailableOutgoingBitrateIssueDetector |
| 87 | +Detects issues with outgoing network connection. |
| 88 | +```js |
| 89 | +{ |
| 90 | + type: 'network', |
| 91 | + reason: 'outbound-network-throughput', |
| 92 | + debug: '...' |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### FramesDroppedIssueDetector |
| 97 | +Detects issues with decoder. |
| 98 | +```js |
| 99 | +{ |
| 100 | + type: 'cpu', |
| 101 | + reason: 'decoder-cpu-throttling', |
| 102 | + debug: '...' |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +### FramesEncodedSentIssueDetector |
| 107 | +Detects issues with outbound network throughput. |
| 108 | +```js |
| 109 | +{ |
| 110 | + type: 'network', |
| 111 | + reason: 'outbound-network-throughput', |
| 112 | + debug: '...' |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +### InboundNetworkIssueDetector |
| 117 | +Detects issues with inbound network connection. |
| 118 | +```js |
| 119 | +{ |
| 120 | + type: 'network', |
| 121 | + reason: 'inbound-network-quality' | 'inbound-network-media-latency' | 'network-media-sync-failure', |
| 122 | + iceCandidate: 'ice-candidate-id' |
| 123 | + debug: '...' |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +Also can detect server side issues if there is high RTT and jitter is ok. |
| 128 | +```js |
| 129 | +{ |
| 130 | + type: 'server', |
| 131 | + reason: 'server-issue', |
| 132 | + iceCandidate: 'ice-candidate-id' |
| 133 | + debug: '...' |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### NetworkMediaSyncIssueDetector |
| 138 | +Detects issues with audio syncronization. |
| 139 | +```js |
| 140 | +{ |
| 141 | + type: 'network', |
| 142 | + reason: 'network-media-sync-failure', |
| 143 | + ssrc: '...' |
| 144 | + debug: '...' |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +### OutboundNetworkIssueDetector |
| 149 | +Detects issues with outbound network connection. |
| 150 | +```js |
| 151 | +{ |
| 152 | + type: 'network', |
| 153 | + reason: 'outbound-network-quality' | 'outbound-network-media-latency', |
| 154 | + iceCandidate: 'ice-candidate-id' |
| 155 | + debug: '...' |
| 156 | +} |
| 157 | +``` |
| 158 | + |
| 159 | +### QualityLimitationsIssueDetector |
| 160 | +Detects issues with encoder and outbound network. Based on native qualitiLimitationReason. |
| 161 | +```js |
| 162 | +{ |
| 163 | + type: 'cpu', |
| 164 | + reason: 'encoder-cpu-throttling', |
| 165 | + ssrc: '...' |
| 166 | + debug: '...' |
| 167 | +} |
| 168 | +``` |
| 169 | + |
| 170 | +```js |
| 171 | +{ |
| 172 | + type: 'network', |
| 173 | + reason: 'outbound-network-throughput', |
| 174 | + ssrc: '...' |
| 175 | + debug: '...' |
| 176 | +} |
| 177 | +``` |
| 178 | + |
| 179 | +### VideoCodecMismatchDetector |
| 180 | +Detects issues with decoding stream. |
| 181 | +```js |
| 182 | +{ |
| 183 | + type: 'stream', |
| 184 | + reason: 'codec-mismatch', |
| 185 | + ssrc: '...', |
| 186 | + trackIdentifier: '...', |
| 187 | + debug: '...' |
| 188 | +} |
| 189 | +``` |
| 190 | + |
| 191 | +## Roadmap |
| 192 | + |
| 193 | +- [ ] Adaptive getStats() call interval based on last getStats() exectution time |
| 194 | +- [ ] Structured issue debug |
| 195 | +- [ ] Issues detector for user devices permissions |
64 | 196 |
|
65 | 197 | ## Test |
66 | 198 | `yarn test` |
|
0 commit comments