postpone starting AudioContext until calling AudioContext.resume() or AudioScheduledSourceNode.start()

RESOLVED FIXED in Firefox 65

Status

()

enhancement
P2
normal
RESOLVED FIXED
7 months ago
5 months ago

People

(Reporter: alwu, Assigned: alwu)

Tracking

(Blocks 1 bug)

unspecified
mozilla65
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox65 fixed)

Details

Attachments

(4 attachments)

(Assignee)

Description

7 months ago
We've finished the implementation in bug1489278, but we still hide this feature behind the pref "media.autoplay.block-webaudio".

Since we want to keep the data which we collect in Bug1490074 precise, and it would be affected if doorhanger shows. 

Therefore, we would delay to turn on this pref until we get enough data.
Priority: -- → P3
(Assignee)

Comment 1

7 months ago
From telemetry data [1], there are at least 25% audio context which starts producing sound 12+ seconds after sites create them. 

If we enable doorhanger for webaudio before handling this issue, the user would see lots of annoying prompt. 
I think we should not enable it until the spec has a better modification about when we should show the prompt [2].

[1] https://telemetry.mozilla.org/new-pipeline/dist.html#!cumulative=0&end_date=2018-10-02&include_spill=0&keys=__none__!__none__!__none__&max_channel_version=nightly%252F64&measure=WEB_AUDIO_BECOMES_AUDIBLE_TIME&min_channel_version=null&processType=*&product=Firefox&sanitize=1&sort_keys=submissions&start_date=2018-09-14&table=0&trim=1&use_submission_date=0

[2] https://github.com/WebAudio/web-audio-api/issues/1759#issuecomment-425417175
(Assignee)

Comment 2

7 months ago
I've tested all websites which are listed in [1], and here are websites which would be broke when we enable blocking autoplay for web audio.

http://frequency-explorer.timpulver.de/
https://musiclab.chromeexperiments.com/Sound-Waves/
https://musiclab.chromeexperiments.com/Harmonics/
http://microscope.timpulver.de/
http://sequ.timpulver.de/
http://fugue-step.timpulver.de/

In addition, for this one, if you click 'allow' button fast enough, then it could work.
https://musiclab.chromeexperiments.com/Rhythm/

I'm not sure why they would be broke, but it seems to me that these websites didn't handle the case of AudioContext not starting immediately.

[1]
https://bugs.chromium.org/p/chromium/issues/detail?id=835767
https://bugs.chromium.org/p/chromium/issues/detail?id=840866
(Assignee)

Comment 3

5 months ago
Hi, Paul,
Could you give me any suggestion about my preliminary patch?
This patch is about to start `AudioContext` when calling `AudioContext.resume()` or `AudioScheduledSourceNode.start()`, otherwise, AudioContext will keep in `suspend` state after it was created.
Thank you!
Attachment #9024893 - Flags: feedback?(padenot)
Comment on attachment 9024893 [details] [diff] [review]
start AudioContext when calling AudioContext.resume() or AudioScheduledSourceNode.start()

I think this would work, but it needs tests.
Attachment #9024893 - Flags: feedback?(padenot) → feedback+
(Assignee)

Updated

5 months ago
Summary: Enable doorhanger for web audio → postpone starting AudioConext until calling AudioContext.resume() or AudioScheduledSourceNode.start()
(Assignee)

Updated

5 months ago
Summary: postpone starting AudioConext until calling AudioContext.resume() or AudioScheduledSourceNode.start() → postpone starting AudioContext until calling AudioContext.resume() or AudioScheduledSourceNode.start()
(Assignee)

Comment 5

5 months ago
If AudioContext is not allowed to start, we would postpone its state transition from `suspended` to `running`
until site explicitly calls AudioContext.resume() or AudioScheduledSourceNode.start().
(Assignee)

Updated

5 months ago
Priority: P3 → P2

Comment 8

5 months ago
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3d997ec4174d
part1 : postpone starting AudioContext until calling AudioContext.resume() or AudioScheduledSourceNode.start(). r=padenot
https://hg.mozilla.org/integration/autoland/rev/3b5ff99abb5e
part2 : modify tests. r=padenot
https://hg.mozilla.org/integration/autoland/rev/345d44957fee
part3 : add test to ensure doorhanger would not dismiss when inaudible media starts. r=cpearce

Comment 9

5 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/3d997ec4174d
https://hg.mozilla.org/mozilla-central/rev/3b5ff99abb5e
https://hg.mozilla.org/mozilla-central/rev/345d44957fee
Status: NEW → RESOLVED
Last Resolved: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
(Assignee)

Updated

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