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

Send unpaced media as padding. #395

Merged

Conversation

pthatcher
Copy link
Collaborator

This prevents a hot loop when you enable RTX for audio and BWE/pacing at the same time without having to know to call .set_unpaced(false) for the audio.

src/packet/pacer.rs Outdated Show resolved Hide resolved
@algesten algesten requested a review from k0nserv November 2, 2023 09:03
QueuePriority::Empty => true,
};
q.snapshot.packet_count > 0 && is_none_empty_queue
});
Copy link
Owner

Choose a reason for hiding this comment

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

At the moment this change looks a bit like it does nothing. We remove !q.unpaced, but then, if there were any content in an unpaced queue, we would have returned earlier. The is_none_empty_queue bool is always true, should we maybe consider this PR a draft given the comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The key to the PR is that "&& !q.unpaced" is removed. That's what fixes that hot loop that's triggered by enabling audio RTX with BWE. But Hugo suggested I also filter out queues with QueuePriority::Padding. But that caused the BWE test called test_realistic to fail.

I would be happy to remove the QueuePriority stuff and just reduce this PR down to removing "&& !q.unpaced", because that's what's important to the fix, and perhaps leave a TODO to look into filtering by QueuePriority.

Copy link
Owner

Choose a reason for hiding this comment

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

This prevents a hot loop when you enable RTX for audio and BWE/pacing at the same time without having to know to call .set_unpaced(false) for the audio.

Is the starting point here right? Is it really meaning to change !q.unpaced?

  • RTX is required for BWE
  • .set_unpaced(false) is required for BWE

Should the default unpaced flag logic be different for this scenario?

We of course want no hot looping, but is the solve here the right one?

Copy link
Collaborator

@k0nserv k0nserv Nov 3, 2023

Choose a reason for hiding this comment

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

The current behaviour is:

  1. We only do BWE calculations on video media
  2. We only pace video media
  3. We only do RTX on video media

At the moment this change looks a bit like it does nothing. We remove !q.unpaced, but then, if there were any content in an unpaced queue, we would have returned earlier. The is_none_empty_queue bool is always true, should we maybe consider this PR a draft given the comment?

The root cause that @pthatcher identified is that we don't set a reasonable fake value for first_unsent when an audio queue only contains padding. We could fix it that way, but that would introduce a new problem(we would prioritize queued padding on an audio queue over queued media on a video queue). This is why we need to remove the !q.unpaced condition.

The priority stuff is not correct I think, just remove that, we already have code that will select the queue with the highest priority.

Copy link
Owner

Choose a reason for hiding this comment

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

  1. We only do BWE calculations on video media
  2. We only pace video media
  3. We only do RTX on video media

It is possible to enable RTX for audio (point 3) and it's possible to turn on pacing for audio (point 2). The only point I'm unsure about is 1 – you mean we don't produce queue stats for audio?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The only point I'm unsure about is 1 – you mean we don't produce queue stats for audio?

No, I was under the impression that we didn't enable TWCC for audio and it therefore wasn't counted, seems we do and I was wrong. It might have been that browsers themselves didn't use to negotiate TWCC for audio

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the QueuePriority stuff. Now the PR just removes the !unpaced check (other than some name/comment cleanup).

By the way, libwebrtc used to not negotiate TWCC for audio by default, but it was always possible to do so (with SDP munging). It does so by default now, last I checked. But that was irrelevant to how I found the bug, which was using the Direct API to enable audio RTX and audio TWCC directly. It will always be possible to enable audio RTX with audio TWCC together.

The real question is: if audio RTX and audio TWCC are enabled, can audio be unpaced? If so, then it shouldn't result in a hot loop. If not, then we need a way of making sure audio is paced when audio TWCC is enabled.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The real question is: if audio RTX and audio TWCC are enabled, can audio be unpaced? If so, then it shouldn't result in a hot loop. If not, then we need a way of making sure audio is paced when audio TWCC is enabled.

Yes it can be, but in theory it shouldn't be. I think the bandwidth of audio might be low enough that it does not matter. The pacing is mostly about avoiding overloading the link when sending large keyframes after all

Copy link
Collaborator

@k0nserv k0nserv left a comment

Choose a reason for hiding this comment

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

LGTM

@pthatcher pthatcher force-pushed the peter/send-padding-with-unpaced-media-pr branch from 6b31b6e to 8d23067 Compare November 9, 2023 05:56
@xnorpx xnorpx merged commit 7583413 into algesten:main Nov 10, 2023
22 checks passed
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.

None yet

4 participants