Skip to content

Conversation

@danxuliu
Copy link
Member

@danxuliu danxuliu commented Jun 28, 2021

Requires #5884 (kept as draft until that is merged, but ready for review nevertheless)

The stats reported by the browser can sometimes stall for a second (it is unclear whether the browser does not update the stats or Janus does not send them, though). When that happens the stats are still reported, but with the same values as in the previous report. As there were no transmitted packets the "very bad quality" state was (wrongly) triggered.

To solve this now if there were no transmitted packets in the last report the analysis is kept on hold. If in the next report the number of packets has changed then the previous report is considered to have stalled and the new values are distributed between the previous and current report. If the number of packets is still zero then the previous report is considered to have been legit and the previous and current values are added as normal.

Besides the main fix this pull request also fixes the stats being wrongly reset when calling "setAnalysisEnabledXXX(true)" twice. This happens whenever the audio or video is enabled while being already enabled. This happens, for example, when another participant joins and the current media state is sent; whether that should happen or not is a different matter, but in any case, calling "setAnalysisEnabledXXX(true)" twice should not reset the stats.

How to test

  • Add a log to know when the stats reported zero transmitted packets (without this pull request, by adding an else clause; with this pull request, by using the else clause in _addStats())
  • Setup the HPB
  • Start a call
  • Leave the call running for a while; sometimes joining and leaving the call with another participant causes the stats to stall

Result with this pull request

Eventually the logs will show that the stats were stalled (zero transmitted packets in a single report), but there will be no logs about the connection quality warning

Result with this pull request

Eventually the logs will show that the stats were stalled (zero transmitted packets in a single report) and there will be logs about the connection quality warning (high lost packet ratio, ~0.45 and then ~0.375, the lost packet ratio values will be similar to [0, 0, 0, 0, 1.5] and then [0, 0, 0, 1.5, 0])

@danxuliu
Copy link
Member Author

/backport to stable22

@danxuliu
Copy link
Member Author

danxuliu commented Jun 28, 2021

/backport to stable21

@PVince81
Copy link
Member

PVince81 commented Jun 30, 2021

the base PR was merged, time to rebase ?

danxuliu added 5 commits July 1, 2021 00:07
The stats were reset whenever "setAnalysisEnabledXXX(true)" was called.
Due to this, if the analysis for audio or video was already enabled and
the method was called again the stats were wrongly reset. The stats
should be reset only when the analysis is really started again.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
This makes the attribute consistent with the stats, and will also make
possible to directly get the quality value given a string identifying
its kind ("audio" or "video").

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
When no packets are transmitted the packet lost ratio is set to a value
higher than 1 to move towards a "no transmitted data" state faster,
although not immediately. Both the "no transmitted data" and "very bad
quality" states are based on the packet lost ratio, so this causes the
"very bad quality" state to be triggered as soon as no packets are
transmitted.

However, the stats reported by the browser can sometimes stall for a
second (it is unclear whether the browser does not update the stats or
Janus does not send them, though). When that happens the stats are still
reported, but with the same values as in the previous report. As there
were no transmitted packets the "very bad quality" state was (wrongly)
triggered.

To solve this now if there were no transmitted packets in the last
report the analysis is kept on hold. If in the next report the number of
packets has changed then the previous report is considered to have
stalled and the new values are distributed between the previous and
current report. If the number of packets is still zero then the previous
report is considered to have been legit and the previous and current
values are added as normal.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu force-pushed the fix-connection-quality-warning-shown-due-to-stalled-stats branch from 76293d8 to aadfd0e Compare July 1, 2021 05:23
@danxuliu danxuliu marked this pull request as ready for review July 1, 2021 05:24
@danxuliu
Copy link
Member Author

danxuliu commented Jul 1, 2021

the base PR was merged, time to rebase ?

Done.

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 code looks fine.

This is becoming quite complex, feels like adding some JS tests is overdue...

@danxuliu
Copy link
Member Author

danxuliu commented Jul 1, 2021

This is becoming quite complex, feels like adding some JS tests is overdue...

Totally. Feel free to add them.

@PVince81 PVince81 merged commit 6c69b18 into master Jul 1, 2021
@PVince81 PVince81 deleted the fix-connection-quality-warning-shown-due-to-stalled-stats branch July 1, 2021 14:26
@backportbot-nextcloud
Copy link

The backport to stable22 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable21 failed. Please do this backport manually.

@PVince81
Copy link
Member

PVince81 commented Jul 1, 2021

need to wait for #5911 before backporting

@PVince81
Copy link
Member

PVince81 commented Jul 1, 2021

/backport to stable22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants