Closed Bug 1941397 Opened 1 year ago Closed 1 year ago

thefreedictionary.com sound clip is truncated when using Bluetooth headphones

Categories

(Core :: Audio/Video: cubeb, defect, P3)

Unspecified
All
defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox134 --- wontfix
firefox135 --- wontfix
firefox136 --- wontfix

People

(Reporter: cpeterson, Unassigned)

References

()

Details

Attachments

(1 file)

Steps to reproduce

  1. Connect to your computer's audio to Bluetooth headphones. I can reproduce this bug in Firefox on both Windows 11 and macOS 15.2 using Bose QC35 II Bluetooth headphones.
  2. Load https://www.thefreedictionary.com/yea
  3. Click the speaker 🔈 button to play a sound clip.

Expected result

The full sound clip should be played saying "yea" like it does in Chrome and Safari on Bluetooth headphones and Firefox on my laptop's builtin speaker.

I should note that Chrome on macOS, but not Windows, does seem to have some minor clipping or crunch when playing this sound clip on my Bluetooth headphones, so there might be some contributing issues outside of Firefox.

Actual result

The sound clip is truncated so it just says "y" or "yi" instead of "yea".

If I switch to Windows or Mac laptop's builtin speaker, Firefox plays the full sound clip. So there is some issue with Firefox's audio playback and (my?) Bluetooth headphones.

I have similar Bluetooth audio issues in Firefox when switching between YouTube videos, but these thefreedictionary.com STR are easier to reproduce.

This is an ancient bug. I can reproduce in a Firefox Nightly build from 2015.

Component: Audio/Video: cubeb → Audio/Video

Can you attach a log with hte "media playback" preset?

Flags: needinfo?(cpeterson)

Feel like having a look at this one?

Flags: needinfo?(apehrson)

I tried with a pair of Sony WH-1000XM5 on macOS and couldn't reproduce. Sorry, I don't have cycles to dig further.

Flags: needinfo?(apehrson)

(In reply to Mayank Bansal from comment #2)

Can you attach a log with hte "media playback" preset?

I enabled "Media playback" in about:logging and logged to this Firefox Profile while I played the audio clip once:

https://share.firefox.dev/4ajIijZ

Flags: needinfo?(cpeterson)

I don't know the Wasapi backend much but the profile seems fine to me.
There's an initial 100ms callback. The remaining callbacks are 10ms until we drain, then it takes ~100ms to finish draining. At no point do we underrun.

From MDSM we push 4676 frames @11025Hz (424126us), resampled to 20359 frames @48kHz.
The AudioStream pops 20839 frames @48kHz (480 frames, i.e. 1 callback, too many?), plus another 281 frames of silence to pad the last callback.

I find it a bit odd -- in other backends when we request 100ms latency (which we always do for playback) we set up callbacks to be 100ms each. Possibly this is just how the Wasapi backend works, or possibly this is symptomatic of your bluetooth setup.

There's one more thing you could do: reproduce with env var MOZ_DUMP_AUDIO=1. Then we'll write a wav file in the current working directory, named "AudioStream-N.wav" containing all audio gecko gave to cubeb's data callback. You'll have to disable the content sandbox temporarily. At least we'll know which side to dig more into then.

Flags: needinfo?(cpeterson)

(In reply to Andreas Pehrson [:pehrsons] from comment #6)

I find it a bit odd -- in other backends when we request 100ms latency (which we always do for playback) we set up callbacks to be 100ms each. Possibly this is just how the Wasapi backend works, or possibly this is symptomatic of your bluetooth setup.

This is the case, Windows generally works in 10ms blocks in the current state of the cubeb backend. E.g. if we're configuring for 48kHz, you get 480 frames, if it's 44100Hz, you get almost always 440 frames, and something a different size to account for the mismatch, etc.

There's one more thing you could do: reproduce with env var MOZ_DUMP_AUDIO=1. Then we'll write a wav file in the current working directory, named "AudioStream-N.wav" containing all audio gecko gave to cubeb's data callback. You'll have to disable the content sandbox temporarily. At least we'll know which side to dig more into then.

Good idea.

Attached audio AudioStream-1.wav —

Here is my AudioStream-1.wav file from my Windows 11 laptop.

When I play this wav file in Windows Media Player, the audio playback is intermittently clipped. When I play this wav file in a Chrome tab or Microsoft's Clipchamp app, the audio playback is always smooth and never clipped, just like when I play the audio clips on thefreedictionary.com directly.

So it seems like the clipping problem I'm experiencing is not limited to Firefox? Does Chrome use a different audio decoder than Firefox and Windows Media Player?

Flags: needinfo?(cpeterson)

Inspecting your dump on wavacity.com tells us gecko is fine -- the full audio is there. So this is an issue in cubeb's wasapi backend or below. What's interesting is that you mentioned macOS as well. In the backend for macOS, cubeb-coreaudio-rs we also have the option to dump the audio as given to the system callbacks. Feel free to enable the audio-dump feature in a local build and reproduce again. The backend runs in the parent process so you shouldn't have to disable any sandbox for this one.

The backends are fully platform dependent code so I'm curious to why you see the same issue on multiple platforms, and I didn't, on macOS at least. I also borrowed a Bose QC45 and could not reproduce with that on macOS either. It seems to me this is hinting towards the device here, but with them working in Chrome it seems like an issue we could find a workaround for.

If you have some audio playing to the headset in the background (possibly from outside Firefox even), are we able to play the full audio clip then? Maybe the system or the device doesn't drain properly when closing the bluetooth stream.

Component: Audio/Video → Audio/Video: cubeb
Flags: needinfo?(cpeterson)
Severity: -- → S3
Priority: -- → P3

I'm going to close this bug as WFM. I'm no longer able to reproduce, even in older builds.

I recently bought new Bluetooth headphones, so maybe this was an issue with my old Bluetooth headphones or its device drivers?

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(cpeterson)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: