goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24.04k stars 2.24k forks source link

Few issues with the latest 2.0 beta 11 #498

Closed jaxtheking closed 8 years ago

jaxtheking commented 8 years ago

Hi, I just updated Howler to the latest v2 beta version to benefits from the upgrades and run into few errors in the console. Nothing big.

The block in the unload function (from line 142) still mentions ctx - which is null. Also close() must be called before nulling self.ctx. Fix:

    // Create a new AudioContext to make sure it is fully reset.
    if (self.usingWebAudio && typeof self.ctx.close !== 'undefined') {
      self.ctx.close();
      self.ctx = null;
      setupAudioContext();
    }

In the mute function (line 107), usingWebAudio should be self.usingWebAudio Fix:

    // With Web Audio, we just need to mute the master gain.
    if (Howler.usingWebAudio) { ...

Hope this helps. Thanks for the one awesome audio library! Luca

clickblipclick commented 8 years ago

Thanks for debugging this. I noticed the first one as well as well (it's breaking everything on some mobile devices because Howler.unload() is called immediately if the sample rate is incorrect).

But if I do your fix, mobile is still broken, because then after unload, on line 242 Howler.ctx is null.

These issues only occur if your device has sample rate of 48000 (discussed on #247).

jaxtheking commented 8 years ago

Ouch - my app just went live as it seemed to be working on the devices I tested it on (e.g. iPhone 6, iPhone 5, Sony Experia, Samsung S2). I mustn't have come across a device with a 48000 sample rate. I'm wondering if I should revert back to 1.x or was it affected by the same problem?

clickblipclick commented 8 years ago

So - I'm not sure exactly, but it does seem to be working with 2.0.0-beta8 (I'm not sure what other issues there are with that one).

goldfire commented 8 years ago

These should be taken care of with d2e3970183e00179695116a42b892e1d29705115 and d3f4085d2866b27644c0c55c15b8015fc2347fdf. Are you still seeing any related problems?

clickblipclick commented 8 years ago

I am still having issues with my iPhone - yes. Seems to be a problem playing sounds at all. And strangely, if I create more than 3 Howl instances, I get the following error:

TypeError: null is not an object (evaluating 'Howler.ctx.createBuffer') in the _enableMobileAudio method.

If I have time later I will try to put together a minimal example.

jaxtheking commented 8 years ago

What iPhone? Is it a 6S? On an iPhone 6 (not S) I'm having no problems at all playing 8 different audio files, fading them out, etc

goldfire commented 8 years ago

I just released beta12, mind checking to see if you are still having these issues?

clickblipclick commented 8 years ago

Yeah, I'm afraid I still have the issue in beta12 on iPhone 5s and a brand new SE. I have a video that plays on the page (assuming it has 48kHz sample rate). Howl sounds play before the video plays, but not after. Then, if I reload the page, I get an error: TypeError: null is not an object (evaluating 'n.ctx.createBuffer') in _enableMobileAudio.

I have to completely close out that Safari window, then it loads fine again, but still no sounds after the video plays.

EDIT: Want to note that this error is happening on the fourth Howl instance that I create, weirdly. If it's 3 I don't encounter the error, but audio still fails to play.

EDIT2: A couple other things I noticed. I logged the error in the try {} catch() in setupAudioContext, and I'm getting audio resources unavailable for AudioContext construction. I'm seeing that each new webkitAudioContext created still has 48kHz sampleRate, so unload is being called for each new Howl, creating new contexts each time, eventually exceeding some limit, I suppose.

EDIT3: Simply commenting the Howler.unload() call seems to work, strangely. Audio plays fine, etc.

goldfire commented 8 years ago

In 7253d7a702d1f173805b538eceef188f7f46a0a2 I've made it so that unload will only happen the first time, can you check if this makes a difference? I'm a little puzzled by the audio resources unavailable for AudioContext construction error since unload closes the context before creating a new one.

JacoBotha commented 8 years ago

I am seeing the same problem on iphone 6S on iOS 9. Each time I load a new howl the previous one gets unloaded. Commenting out the Howler.unload() does fix it but may cause the sample rate issue again. Is there any other updates on this issue?

Edit : I am on Beta12

goldfire commented 8 years ago

@JacoBotha The commit I mention in the previous comment is not in beta12, can you try that?

JacoBotha commented 8 years ago

@goldfire This seems to have fixed the issue, will do some more testing and get back to you. Thanks