Skip to content

Commit

Permalink
Disable redundant audio for Chrome 106 and earlier (#2841)
Browse files Browse the repository at this point in the history
Co-authored-by: Shi Su <shisuss@amazon.com>
  • Loading branch information
shi-su and Shi Su authored Feb 12, 2024
1 parent 5794e34 commit d477baf
Show file tree
Hide file tree
Showing 15 changed files with 2,699 additions and 2,612 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix reconnections when setting audio Attendee Capability to 'None' or 'Send' mid call. The connection health monitor will now look at all packets received on all candidate pairs instead of just audio received media packets.
- Setup passthrough streams for insertable streams case in the redundant audio worker so that passthrough streams do not get blocked on the main thread
- Setup passthrough streams for insertable streams case in the redundant audio worker so that passthrough streams do not get blocked on the main thread.
- Disable redundant audio for Chrome 106 and earlier to fix video decoder failure on old Chrome versions with redundant audio turned on.

## [3.19.0] - 2023-09-20

Expand Down
2 changes: 1 addition & 1 deletion demos/browser/app/meetingV2/meetingV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ export class DemoMeetingApp
}
);

if (this.defaultBrowserBehavior.hasFirefoxWebRTC()) {
if (!this.defaultBrowserBehavior.supportsAudioRedundancy()) {
// Firefox currently does not support audio redundancy through insertable streams or
// script transform so disable the redundancy checkbox
(document.getElementById('disable-audio-redundancy') as HTMLInputElement).disabled = true;
Expand Down
5,172 changes: 2,590 additions & 2,582 deletions docs/assets/js/search.js

Large diffs are not rendered by default.

60 changes: 41 additions & 19 deletions docs/classes/defaultbrowserbehavior.html

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions docs/interfaces/extendedbrowserbehavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ <h3>Methods</h3>
<li class="tsd-kind-method tsd-parent-kind-interface"><a href="extendedbrowserbehavior.html#supportdownlinkbandwidthestimation" class="tsd-kind-icon">support<wbr>Downlink<wbr>Bandwidth<wbr>Estimation</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-inherited"><a href="extendedbrowserbehavior.html#supportstring" class="tsd-kind-icon">support<wbr>String</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-inherited"><a href="extendedbrowserbehavior.html#supportedvideocodecs" class="tsd-kind-icon">supported<wbr>Video<wbr>Codecs</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><a href="extendedbrowserbehavior.html#supportsaudioredundancy" class="tsd-kind-icon">supports<wbr>Audio<wbr>Redundancy</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><a href="extendedbrowserbehavior.html#supportsbackgroundfilter" class="tsd-kind-icon">supports<wbr>Background<wbr>Filter</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-inherited"><a href="extendedbrowserbehavior.html#supportscanvascapturedstreamplayback" class="tsd-kind-icon">supports<wbr>Canvas<wbr>Captured<wbr>Stream<wbr>Playback</a></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><a href="extendedbrowserbehavior.html#supportsdependencydescriptorrtpheaderextension" class="tsd-kind-icon">supports<wbr>Dependency<wbr>Descriptor<wbr>Rtp<wbr>Header<wbr>Extension</a></li>
Expand All @@ -146,7 +147,7 @@ <h3>disable480p<wbr>Resolution<wbr>Scale<wbr>Down</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/browserbehavior/ExtendedBrowserBehavior.ts#L35">src/browserbehavior/ExtendedBrowserBehavior.ts:35</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/browserbehavior/ExtendedBrowserBehavior.ts#L36">src/browserbehavior/ExtendedBrowserBehavior.ts:36</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
Expand Down Expand Up @@ -438,7 +439,7 @@ <h3>requires<wbr>Playback<wbr>Latency<wbr>Hint<wbr>For<wbr>Audio<wbr>Context</h3
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/browserbehavior/ExtendedBrowserBehavior.ts#L39">src/browserbehavior/ExtendedBrowserBehavior.ts:39</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/browserbehavior/ExtendedBrowserBehavior.ts#L40">src/browserbehavior/ExtendedBrowserBehavior.ts:40</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -552,6 +553,23 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface">
<a name="supportsaudioredundancy" class="tsd-anchor"></a>
<h3>supports<wbr>Audio<wbr>Redundancy</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface">
<li class="tsd-signature tsd-kind-icon">supports<wbr>Audio<wbr>Redundancy<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/browserbehavior/ExtendedBrowserBehavior.ts#L35">src/browserbehavior/ExtendedBrowserBehavior.ts:35</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface">
<a name="supportsbackgroundfilter" class="tsd-anchor"></a>
<h3>supports<wbr>Background<wbr>Filter</h3>
Expand Down Expand Up @@ -763,6 +781,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</s
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-inherited">
<a href="extendedbrowserbehavior.html#supportedvideocodecs" class="tsd-kind-icon">supported<wbr>Video<wbr>Codecs</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-interface">
<a href="extendedbrowserbehavior.html#supportsaudioredundancy" class="tsd-kind-icon">supports<wbr>Audio<wbr>Redundancy</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-interface">
<a href="extendedbrowserbehavior.html#supportsbackgroundfilter" class="tsd-kind-icon">supports<wbr>Background<wbr>Filter</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/audioprofile/AudioProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class AudioProfile {
constructor(audioBitrateBps: number | null = null, enableAudioRedundancy: boolean = true) {
this.audioBitrateBps = audioBitrateBps;
this.enableAudioRedundancy =
!new DefaultBrowserBehavior().hasFirefoxWebRTC() && enableAudioRedundancy;
new DefaultBrowserBehavior().supportsAudioRedundancy() && enableAudioRedundancy;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/browserbehavior/DefaultBrowserBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ export default class DefaultBrowserBehavior implements BrowserBehavior, Extended
);
}

supportsAudioRedundancy(): boolean {
if (this.hasChromiumWebRTC()) {
// Audio redundancy may cause video decoding failure for Chromium version 106 and
// earlier. Marking such Chromium versions as not supporting audio redundancy.
return this.engineMajorVersion() >= 107;
}
return !this.hasFirefoxWebRTC();
}

requiresResolutionAlignment(width: number, height: number): [number, number] {
if (this.isAndroid() && this.isPixel3()) {
return [Math.ceil(width / 64) * 64, Math.ceil(height / 64) * 64];
Expand Down
1 change: 1 addition & 0 deletions src/browserbehavior/ExtendedBrowserBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default interface ExtendedBrowserBehavior extends BrowserBehavior {
supportsVideoLayersAllocationRtpHeaderExtension(): boolean;
supportsDependencyDescriptorRtpHeaderExtension(): boolean;
supportsScalableVideoCoding(): boolean;
supportsAudioRedundancy(): boolean;
disable480pResolutionScaleDown(): boolean;
/**
* Returns whether the browser requires the "playback" latency hint for Web Audio.
Expand Down
4 changes: 2 additions & 2 deletions test/audioprofile/AudioProfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('AudioProfile', () => {
});

describe('constructor', () => {
it('can be constructed correctly in chrome', () => {
it('can be constructed correctly in chrome 107 and later', () => {
const domMockBehavior: DOMMockBehavior = new DOMMockBehavior();
domMockBehavior.browserName = 'chrome';
domMockBehavior.browserName = 'chrome116';
domMockBuilder = new DOMMockBuilder(domMockBehavior);
expect(new AudioProfile().audioBitrateBps).to.equal(null);
expect(new AudioProfile().hasRedundancyEnabled()).to.equal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4435,7 +4435,7 @@ describe('DefaultAudioVideoController', () => {

it('can be started', async () => {
configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers = true;
domMockBehavior.browserName = 'chrome';
domMockBehavior.browserName = 'chrome116';
domMockBuilder = new DOMMockBuilder(domMockBehavior);
audioVideoController = new DefaultAudioVideoController(
configuration,
Expand Down
22 changes: 22 additions & 0 deletions test/browserbehavior/DefaultBrowserBehavior.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,26 @@ describe('DefaultBrowserBehavior', () => {
expect(new DefaultBrowserBehavior().supportsScalableVideoCoding()).to.be.true;
});
});

describe('Audio redundancy support', () => {
it('Does not support audio redundancy for firefox', () => {
setUserAgent(FIREFOX_MAC_USER_AGENT);
expect(new DefaultBrowserBehavior().supportsAudioRedundancy()).to.be.false;
});

it('Does not support audio redundancy for chrome earlier than version 107', () => {
setUserAgent(CHROMIUM_EDGE_WINDOWS_USER_AGENT);
expect(new DefaultBrowserBehavior().supportsAudioRedundancy()).to.be.false;
});

it('Supports audio redundancy for chrome version 107 or later', () => {
setUserAgent(CHROME_116_MAC_USER_AGENT);
expect(new DefaultBrowserBehavior().supportsAudioRedundancy()).to.be.true;
});

it('Supports audio redundancy for Safari', () => {
setUserAgent(SAFARI_USER_AGENT);
expect(new DefaultBrowserBehavior().supportsAudioRedundancy()).to.be.true;
});
});
});
3 changes: 3 additions & 0 deletions test/dommock/DOMMockBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,12 @@ export default class DOMMockBuilder {
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/604.1';
const SAMSUNG_INTERNET_USERAGENT =
'Mozilla/5.0 (Linux; Android 11; Pixel 3a XL) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/13.0 Chrome/83.0.4103.106 Mobile Safari/537.36';
const CHROME_116_MAC_USER_AGENT =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36';

const USER_AGENTS = new Map<string, string>();
USER_AGENTS.set('chrome', CHROME_USERAGENT);
USER_AGENTS.set('chrome116', CHROME_116_MAC_USER_AGENT);
USER_AGENTS.set('firefox', FIREFOX_USERAGENT);
USER_AGENTS.set('safari', SAFARI_USERAGENT);
USER_AGENTS.set('safari12', SAFARI12_USERAGENT);
Expand Down
2 changes: 1 addition & 1 deletion test/task/AttachMediaInputTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('AttachMediaInputTask', () => {

it('sets the correct audio codec preference if audio redundancy is enabled', done => {
domMockBehavior = new DOMMockBehavior();
domMockBehavior.browserName = 'chrome';
domMockBehavior.browserName = 'chrome116';
domMockBehavior.supportsAudioRedCodec = true;
domMockBuilder = new DOMMockBuilder(domMockBehavior);
context.audioProfile = new AudioProfile();
Expand Down
2 changes: 1 addition & 1 deletion test/task/SetLocalDescriptionTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('SetLocalDescriptionTask', () => {

it('will call setAudioPayloadTypes of transceiverController', async () => {
domMockBehavior = new DOMMockBehavior();
domMockBehavior.browserName = 'chrome';
domMockBehavior.browserName = 'chrome116';
domMockBuilder = new DOMMockBuilder(domMockBehavior);
context.transceiverController = new DefaultTransceiverController(
context.logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('DefaultTransceiverController', () => {
const context: AudioVideoControllerState = new AudioVideoControllerState();

beforeEach(() => {
domMockBehavior.browserName = 'chrome';
domMockBehavior.browserName = 'chrome116';
domMockBuilder = new DOMMockBuilder(domMockBehavior);

// Wrap the mock worker to initialize the RED worker since the worker code at the URL is not actually executed.
Expand Down

0 comments on commit d477baf

Please sign in to comment.