[Webkit-unassigned] [Bug 216972] New: Calling suspend() on audio context with no node does not prevent auto transition to running when first node is created

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 25 06:42:20 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=216972

            Bug ID: 216972
           Summary: Calling suspend() on audio context with no node does
                    not prevent auto transition to running when first node
                    is created
           Product: WebKit
           Version: Safari 13
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Audio
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: fd at w3.org

Created attachment 409686

  --> https://bugs.webkit.org/attachment.cgi?id=409686&action=review

Test HTML page to reproduce the bug

If one calls suspend() on an audio context before any node has been created, the call succeeds (and state right after is indeed "suspended") but the intent is ignored: the audio context still switches to "running" automatically when a first node gets created. This is counter-intuitive.

Steps to Reproduce:

Run the following code in response to some user gesture. See attached file for an HTML page that contains the test.

const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioContext = new AudioContext();
await audioContext.suspend();
const node = audioContext.createOscillator();

Actual state after creation of the oscillator node is "running". Since the code explicitly called suspend(), I would rather expect the audio context to remain in a "suspended" state.


Working around this behavior is easy, one can either:

1. call suspend() after creating the first node

2. call resume() before suspend() leading to the following (weird) workaround:
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioContext = new AudioContext();
await audioContext.resume();
await audioContext.suspend();
const node = audioContext.createOscillator();

The attached HTML page renders 3 buttons. First button illustrates the bug. Second and third button illustrate the workarounds.

I note that this may warrant an update to the Web Audio API specification, as it does not explicitly state that the initial transition to running (delayed in Webkit as allowed by the spec) needs to take the [[suspended by user]] flag into account. It seems reasonable to assume that when the developer calls suspend(), they actually mean it, though!

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200925/c42396e6/attachment-0001.htm>


More information about the webkit-unassigned mailing list