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

Do no enqueue any audio payloads larger than 1000 bytes #2791

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

dinmin-amzn
Copy link
Contributor

Issue #: n/a

Description of changes:
In Chromium-based browsers, writing audio payloads larger than 1000 bytes using the WebRTC Insertable Streams API (which is used to enable dynamic audio redundancy) will cause an error to be thrown and cause audio flow to permanently stop. See https://crbug.com/1248479.

Testing:

Can these tested using a demo application? Please provide reproducible step-by-step instructions.

  1. Have attendee A join with the Set fullband music (stereo) quality selected (this will cause the audio frames to be especially large due to the higher quality)
  2. Have attendee B join normally
  3. Start content share from attendee A, select a tab that actually has audio, and enable the Also share tab audio option
  4. Use Network Link Conditioner to simulate >20% downlink packet loss (this will cause the downlink packets to contain up to 2 extra RED packets and have up to 3x the audio payload size)
  5. Attendee B should NOT see the Uncaught (in promise) DOMException: Failed to execute 'write' on 'UnderlyingSinkBase': Frame too large error and Attendee B should receive audio normally

Checklist:

  1. Have you successfully run npm run build:release locally?
    y

  2. Do you add, modify, or delete public API definitions? If yes, has that been reviewed and approved?
    n

  3. Do you change the wire protocol, e.g. the request method? If yes, has that been reviewed and approved?
    n

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

* 1000 bytes is enqueued. Any controller that attempts to enqueue an audio payload larger than 1000 bytes will
* encounter this error and will permanently stop sending or receiving audio.
*/
private maybeEnqueueAudioFrame(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since its such a short function we can probably make the name explicit, maybe enqueueAudioFrameIfPayloadSizeIsValid? Borderline too verbose, up to you. I myself have felt a bit mid towards the prefix 'maybe' after using it a bit over the years.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can go the verbose route as this is a private function anyway. I only used maybe since it looked like an existing pattern but I'm not strongly for that pattern either.

const enqueueSpy = sinon.spy(controller, 'enqueue');

expect(enqueueSpy.calledOnce).to.be.false;
frame.data = new ArrayBuffer(encoder['maxAudioPayloadSizeBytes'] - 1);
Copy link
Contributor

@hensmi-amazon hensmi-amazon Oct 27, 2023

Choose a reason for hiding this comment

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

No way to test this without these private function accesses? Also, i'm pretty sure standard practice is to avoid using constants from non test code in tests. Not a big deal though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to change this to test these cases without the need for private function accesses.

Copy link
Contributor Author

@dinmin-amzn dinmin-amzn Nov 1, 2023

Choose a reason for hiding this comment

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

I didn't avoid the private function accesses completely since it would have required a lot more mocking that seemed overkill for this small change, but I did update the tests to more closely resemble the actual edge cases that this change would protect against.

hensmi-amazon
hensmi-amazon previously approved these changes Oct 27, 2023
In Chromium-based browsers, writing audio payloads larger than 1000 bytes using
the WebRTC Insertable Streams API (which is used to enable dynamic audio
redundancy) will cause an error to be thrown and cause audio flow to permanently
stop. See https://crbug.com/1248479.
@dinmin-amzn dinmin-amzn merged commit dc32d47 into main Nov 2, 2023
10 checks passed
@dinmin-amzn dinmin-amzn deleted the redlimit branch November 2, 2023 22:34
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.

3 participants