Closed Bug 1773577 Opened 2 years ago Closed 2 years ago

Enable the pref `media.autoplay.block-webaudio`

Categories

(Core :: Audio/Video: Playback, task, P2)

task

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

Details

Attachments

(1 file)

The reason we didn't enable this pref is because based on our old telemetry data (WEB_AUDIO_AUTOPLAY) still showed that there were a half of cases where the web audio would never be unblocked. We thought that might be a sign of breaking websites.

Chrome enabled blocking web audio on 71 and Safari also block web audio, so maybe we should not treat those never-unblocked cases as a sign of breaking sites, they might be other use cases which doesn't affect the user experience.

In addition, we also enable this old feature on Nightly for a long while and didn't see any related bug report. So it might be a time to enable this feature now.

Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/afb7205c7b9f
enable the pref 'media.autoplay.block-webaudio'. r=padenot
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch

Hi Alastor!

Docs for this changed in https://github.com/mdn/content/issues/24311. Note, that the docs say this:

media.autoplay.block-webaudio
A Boolean preference which indicates whether to apply autoplay blocking to the Web Audio API.

My understanding is that this means that by default the if you use the web audio API (audiocontext) the content won't autoplay. That means first time you come to a site the content won't autoplay. So what are the conditions to make it autoplay?

  • transient user interaction?
  • sticky user interaction?
  • Can you enable with permission policy?
  • Something else?
Flags: needinfo?(alwu)

Web audio spec requires the sticky user activation, so there is no way to start a AudioContext before the page gets activated by the sticky user activation. Only exception is for Offline Audio Context, which is not regarded as a target for blocking autoplay because it won't output any sound to audio devices.

After the sticky activation has been performed on the page, there are ways to start AudioContext
(1) calling AudioContext.resume()
(2) calling AudioScheduledSourceNode.start() which has been attached to the targeted AudioContext
(3) connect a MediaStreamAudioSourceNode to targeted AudioContext and start that node

There are some examples you can refer.

Flags: needinfo?(alwu)

Thanks Alastor - I read it as "may" not "must" have sticky user activation:

"A user agent may disallow this initial transition, and to allow it only when the AudioContext's relevant global object has sticky activation."

In any case, I think what you're saying is that this preference is what FF uses to enforce sticky activation. If you were to set this false then autoplay might be allowed?

Flags: needinfo?(alwu)

Sorry for my late reply. Yes, if the pref is false, then web audio won't be blocked and always be allowed to autoplay.

Flags: needinfo?(alwu)
Blocks: 1818840
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: