Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only process mute events if a timer fired to avoid video flashing. #2147

Merged
merged 3 commits into from
May 12, 2020

Conversation

alexamirante
Copy link
Member

@alexamirante alexamirante commented May 9, 2020

In the last couple of days I happened to have a crappy network as my ISP is having troubles, so I tried to better study the video flashing issue described in #2145.

By printing the time passed between mute and unmute events raised by Chrome and plotting them into a graph, I found out that this is always a multiple of 834 ms:
timing
I have no idea where this value comes from, but it's important to take it into account when setting the timeout @SchoolCoder suggested. I rounded that value to 840 ms and set the timeout to three times that value (~2.5 seconds) which seems acceptable to me. This made most video flashing disappear in my crappy network.

I suck pretty bad at JavaScript, but it seemed easy enough to arrange a Pull Request.

Fixes #2145.

Janus.log("Adding onended callback to track:", event.track);
event.track.onended = function(ev) {
Janus.log("Remote track muted/removed:", ev);
if(config.remoteStream) {
config.remoteStream.removeTrack(ev.target);
pluginHandle.onremotestream(config.remoteStream);
clearTimeout(trackMutedTimeoutId);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be a if(trackMutedTimeoutId != null) { here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

calling clearTimeout(null) just does nothing:

Passing an invalid ID to clearTimeout() silently does nothing; no exception is thrown.

so I don't think is actually needed.

@alexamirante
Copy link
Member Author

@atoppi double-check please

@atoppi
Copy link
Member

atoppi commented May 11, 2020

lgtm 👍

@lminiero
Copy link
Member

Merging.

@lminiero lminiero merged commit bb86acf into meetecho:master May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Janus.js handling of track muting/unmuting causes video flashing in Chrome
3 participants