Bug 212653 - Web Audio AnalyserNode returning bad values for bluetooth headset input volume.
Summary: Web Audio AnalyserNode returning bad values for bluetooth headset input volume.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: Safari 13
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-02 13:36 PDT by Jon Mudrick
Modified: 2020-06-02 18:28 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Mudrick 2020-06-02 13:36:59 PDT
This issue affects iOS and macOS devices with a pre-attached set of bluetooth headphones being used as an input. First noticed with AirPods Pro and Airpods.

If I try to create an analyser from a fresh AudioContext (using audioContext.createAnalyser() with an appropriate audio input source selected), created when a bluetooth device is connected to the device, any attempts to get volume data returns numbers near 0 instead of proper values. 
I'm using code similar to the example code found here: https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData 
The above link has a demo page (https://mdn.github.io/voice-change-o-matic/) which exhibits the bad behavior.

Some supporting details:
All Data functions on the AnalyserNode return bad values (getFloatFrequencyData, getByteFrequencyData, getFloatTimeDomainData, getByteTimeDomainData)
On iOS, where the only input device option from a call to enumerateDevices is just "iPhone Microphone":
- If no bluetooth headset is connected when the analyser is created, and then a bluetooth headset is subsequently connected, correct data is reported by the AnalyserNode.
- If a bluetooth headset is connected when the analyser is created, no correct data is reported by the AnalyserNode, even after the bluetooth headset is disconnected.

On macOS:
- Multiple audio inputs are available from enumerateDevices, as it can select from the built-in mic and the headset.
- If an AnalyserNode is created from the bluetooth headset, it does not report correct data, but if an AnalyserNode is created from the built-in mic, it works correctly.

I have witnessed similar behavior in chromium-based browsers on Windows, but only with AirPods, not with other types of bluetooth headphones I have handy.
Comment 1 Radar WebKit Bug Importer 2020-06-02 18:28:15 PDT
<rdar://problem/63902783>