Bug 190410 - REGRESSION (Safari 12): User gesture after few seconds leads to audio context resuming but no sound
Summary: REGRESSION (Safari 12): User gesture after few seconds leads to audio context...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac macOS 10.13
: P2 Normal
Assignee: Nobody
Keywords: InRadar, Regression
Depends on:
Reported: 2018-10-09 13:42 PDT by Jordan Nelson
Modified: 2022-06-23 13:33 PDT (History)
5 users (show)

See Also:

webaudio-after-5s.html (945 bytes, text/html)
2018-10-10 17:47 PDT, Jer Noble
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jordan Nelson 2018-10-09 13:42:37 PDT
On Safari 12, I am trying everything I can to get audio to have sound.  It was working on Safari 11, but not on Safari 12.
In the app, calling resume() on the audioContext after a user interaction gets the audio context out of suspended and into running in all cases.  So I am assuming that it is "allowed to start" per Web Audio API.
However, if user interaction is within ~5 seconds of loading the page, sound comes out.  If after 5 seconds, no sound.

    function fixAudioContext() {
      console.log("1: " + audioContext.state);
      return audioContext.resume().then(function() {
        console.log("2: " + audioContext.state);
        var buffer = audioContext.createBuffer(1, 1, 22050);
        var source = audioContext.createBufferSource();
        source.buffer = buffer;
        // Connect to output (speakers)
        // Play sound
        if (source.start) {
        } else if (source.play) {
        } else if (source.noteOn) {
        console.log("3: " + audioContext.state);
      .catch(function() {

After 5 seconds console still prints, "1: suspended, 2: running, 3: running" but no sound.  The creating buffer stuff is an attempt to play a silent sound to warm up the context.  Honestly just a shot in the dark.
Comment 1 Radar WebKit Bug Importer 2018-10-10 16:25:25 PDT
Comment 2 Jer Noble 2018-10-10 17:47:23 PDT
Created attachment 352003 [details]

Hi Jordan,

I fleshed out your example a bit, and used an oscillatorNode instead of a audioSourceBufferNode, just so I could hear the results, and it definitely seems to be audible, no matter how long I wait before hitting the button. Could you post a more complete version of your test case?
Comment 3 Jordan Nelson 2018-10-11 12:45:02 PDT
Jer Noble,

  I setup a mini example demo myself to try to reproduce, but it was working as expected.  I finally found the bug in my application code that was causing the strange time dependent behavior.  This ticket can be closed out because there is nothing wrong.  Thank you so much for responding.