RESOLVED INVALID 190410
REGRESSION (Safari 12): User gesture after few seconds leads to audio context resuming but no sound
https://bugs.webkit.org/show_bug.cgi?id=190410
Summary REGRESSION (Safari 12): User gesture after few seconds leads to audio context...
Jordan Nelson
Reported 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. Thanks. 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) source.connect(audioContext.destination); // Play sound if (source.start) { source.start(0); } else if (source.play) { source.play(0); } else if (source.noteOn) { source.noteOn(0); } console.log("3: " + audioContext.state); audioContextDeferred.resolve(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.
Attachments
webaudio-after-5s.html (945 bytes, text/html)
2018-10-10 17:47 PDT, Jer Noble
no flags
Radar WebKit Bug Importer
Comment 1 2018-10-10 16:25:25 PDT
Jer Noble
Comment 2 2018-10-10 17:47:23 PDT
Created attachment 352003 [details] webaudio-after-5s.html 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?
Jordan Nelson
Comment 3 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. Sincerely, Jordan
Note You need to log in before you can comment on or make changes to this bug.