Skip to content

Commit 048c505

Browse files
committed
fix: Fix quality report when packet count regresses
Due to a bug in Firefox and/or Janus, when using simulcast video the remote report for one of the streams (typically the lowest quality one) may start with garbage values. This causes the received packet count to be reported the maximum integer value minus the packet lost count (which is usually around a few thousands). When newer stats arrive the received packets start to increase from that extremely high value, and eventually it overflows, causing the received packet count to go back from ~4294967295 to ~0. In other cases it was seen that the received packet count can regress a few values, although it is not clear when or why (this was much rarer and not reproducible, unlike the scenario described above). To prevent the regressed value from distorting the analysis due to the packet count being < 0, and as in both cases once the packet count regressed the received packet count in all following stat reports increase from the regressed value, now the stats are reset when a lower packet count is found. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
1 parent 70530ac commit 048c505

File tree

2 files changed

+688
-0
lines changed

2 files changed

+688
-0
lines changed

src/utils/webrtc/analyzers/PeerConnectionAnalyzer.js

+13
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,19 @@ PeerConnectionAnalyzer.prototype = {
396396
packetsLost[kind] = this._packetsLost[kind].getLastRawValue()
397397
}
398398

399+
// In some (also strange) cases a newer stat may report a lower
400+
// value than a previous one (it happens sometimes with garbage
401+
// remote reports in simulcast video that cause the values to
402+
// overflow, although it was also seen with a small value regression
403+
// when enabling video). If that happens the stats are reset to
404+
// prevent distorting the analysis with negative packet counts; note
405+
// that in this case the previous value is not kept because it is
406+
// not just an isolated wrong value, all the following stats
407+
// increase from the regressed value.
408+
if (packets[kind] >= 0 && packets[kind] < this._packets[kind].getLastRawValue()) {
409+
this._resetStats(kind)
410+
}
411+
399412
this._addStats(kind, packets[kind], packetsLost[kind], timestamp[kind], roundTripTime[kind])
400413
}
401414
},

0 commit comments

Comments
 (0)