Closed Bug 1724994 Opened 4 months ago Closed 3 months ago

[Bug]: Reduced audio quality on SoundCloud when tab does not have focus

Categories

(Core :: Audio/Video: Playback, defect)

Unspecified
Android
defect

Tracking

()

RESOLVED FIXED
93 Branch
Tracking Status
firefox93 --- fixed

People

(Reporter: kbrosnan, Assigned: padenot)

Details

(Whiteboard: [media-audio])

Attachments

(1 file, 1 obsolete file)

From github: https://github.com/mozilla-mobile/fenix/issues/20653.

Steps to reproduce

  1. Open https://m.soundcloud.com/discover/sets/charts-top:piano:us (or another chart with music that has minimal distortion, so you can hear the issue more clearly)
  2. Play a track and it should be very clear with very rare crackling sounds
  3. Change focus away from the tab, for example, to the Android home screen or another app, and a very brief crackling sound may occur immediately and then intermittently as the track plays

Expected behaviour

Background audio plays smoothly on other sites, such as YouTube (with the "Video Background Play Fix" add-on installed) and my local public radio station (KQED FM, click the Listen Live button), so the expectation is that SoundCloud also would work seamlessly.

Actual behaviour

Intermittent crackling sounds. Here's the SoundCloud user's latest thread: https://support.mozilla.org/questions/1345089

Device name

Sony Xperia 10 II dual

Android version

Android 11

Firefox release type

Firefox

Firefox version

89+

Device logs

No response

Additional information

Confirmed in Firefox Nightly 92.0a1 on Samsung Galaxy S20 FE 5G with Android 11.

Change performed by the Move to Bugzilla add-on.

I can hear some cracking sound but not so serious as what the reporter experienced, and that issue won't happen on normal playback, eg. this page. I know SoundCloud uses WebAudio API, and I wonder if web audio API would get restricted on performace when the page is in background? Paul, do you have any thought about that?
Thank you.

Flags: needinfo?(padenot)

I'm pretty sure I've seen that on my devices. Wouldn't it be related/fixed by your recent work on Web Audio API/document suspend on Android ?

Flags: needinfo?(padenot) → needinfo?(alwu)

No, I have tested the latest Nightly which already contains the suspend improvement for web audio, but that doesn't help. So that makes me wonder if there is other factor which decrease the web audio performance.

Flags: needinfo?(alwu) → needinfo?(padenot)

Taking for initial investigation, I'll try to reproduce on my devices, I think I can on one of my Sony devices for some reason, but I'm not sure.

Assignee: nobody → padenot
Flags: needinfo?(padenot)
Severity: -- → S4
Whiteboard: media-audio
Whiteboard: media-audio → [media-audio]

This appears to be because of the GraphRunner, because it isn't promoted on Android.

What's needed is to add Android support to https://github.com/padenot/audio_thread_priority. This means doing JNI stuff from Rust.

Diagnosing note:

  • Doing real-time profiling + using https://github.com/padenot/fx-profiler-audio-cb shows that all underruns are happening at a context switch
  • Disabling AudioWorklet via the pref and the GraphRunner thread also via the pref results in playing soundcloud for a good 20min without underruns, while it was underruning quite quickly before
Attachment #9237494 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch

Not a big deal to patch in our fork, but that would make b2g life easier if this patch used MOZ_WIDGET_ANDROID instead of ANDROID for things that depends on the Android sdk and not just the ndk. Thanks!

Sorry about that Fabrice, patch to switch to MOZ_WIDGET_ANDROID is in bug 1728279.

thanks Paul!

You need to log in before you can comment on or make changes to this bug.