Jump to content

[Safari 9 Desktop] Totally weird audio bug. Audio only after reloading a page (ignore caching)


george
 Share

Recommended Posts

Hi guys,

I need your help. This small page is producing a code in Firefox, Firefox ESR, Chrome on OSX each with its latest release.

But it's not working as expected in Safari 9.

 

Here is the very very reduced example:

http://www.2vc.org/audio-bug/

 

Surprisingly it is working on jsfiddle which doesn't make it any more logical

http://jsfiddle.net/pg072s2r/

 

I don't get any sound output in safari 9 (still under yosemite) on the first page load. But if I reload it works as expected for any successive reload. There are no external files involved. So what the heck is happening here? This currently happens in my larger project with large files I am decoding and also in this small example.

 

Can someone confirm this? I'm looking into this for some days now and I just don't get it? What do I miss? It feels like a bug that can't be a real bug but rather is some stupid error on my site. 

 

Thanks for looking into this. Btw this is the code- easy isn't it?

var AudioContext = window.AudioContext || window.webkitAudioContext;var ac = new AudioContext();var oscillator = ac.createOscillator();oscillator.frequency.value = 200;oscillator.connect(ac.destination);oscillator.start();

Thanks for taking your time.

Regards George

Link to comment
Share on other sites

Hi Alex,

so this happen also for you? And yeah I tried many, many different combinations on the way done from my large project down to this example. Sometimes it worked on click, on timeout but I just wanted to get back to a very basic example to get it confirmed. I mean it simply must work on a desktop browser. I will wait for other responses and continue to search an existing bug ticket for webkit for this.

 

Btw I also tried applying chris wilsons monkey patch- as it might fix some known issues. But still the same.

https://github.com/cwilso/AudioContext-MonkeyPatch

 

Regards

George

Link to comment
Share on other sites

I updated my testcase and prepared three workarounds. All of them deal with the state of the involved audio context.

It's suspened at the beginning and we can resume it without user interaction or even with mousemove until it's fixed. I hope this can fix my project as it's a little bit more complex

 

Her the update:

http://www.2vc.org/audio-bug/

Link to comment
Share on other sites

This is my workaround which works superb at the moment. I use a timeout and trigger a resume on the audio context- which is suspended for whatever reason.

function fixSuspendedState(ac){  if(ac.state == 'suspended'){    log.warn('AudioContext FIX: suspended. Try to wake it.')        if(ac.resume){      ac.resume();    }        return ac.state == 'running';    }else{    log.warn('AudioContext FIX: not suspended, nothing to do.')    return true;  }}function fix(ac){  if(ac.state == 'running') return;//nothing to do  setTimeout(function(){    var fixed = fixSuspendedState(ac);    log.warn('AudioContext FIX: Applied, state is', fixed);  }, 2000)}var ac = new AudioContext(); //wherever you are doing thisfix(ac);//fix it
Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...