Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidStateError: Failed to execute 'stop' on 'AudioBufferSourceNode' #226

Closed
ghost opened this issue Oct 16, 2014 · 10 comments
Closed

InvalidStateError: Failed to execute 'stop' on 'AudioBufferSourceNode' #226

ghost opened this issue Oct 16, 2014 · 10 comments
Milestone

Comments

@ghost
Copy link

ghost commented Oct 16, 2014

I got this error sometimes:

** Uncaught InvalidStateError: Failed to execute 'stop' on 'AudioBufferSourceNode': cannot call stop without calling start first. **

I can reproduce it when I try to play/stop multiple sounds at the same time.
I'm on osx with Chrome Version 39.0.2171.27 beta (64-bit)

Any suggestion?

Related to this:
Uncaught InvalidStateError: Failed to execute 'start' on 'AudioBufferSourceNode': Duration must be a finite non-negative number: -1.12327

  • Howler.js: line 506.
@just-jeb
Copy link

Have the same issue: "Uncaught InvalidStateError: Failed to execute 'start' on 'AudioBufferSourceNode': Duration must be a finite non-negative number".
howler.min.js:10

Chrome version 38.0.2125.122.

Certainly it is related to one of chrome updates, because it worked before (the same code).
Unfortunately can't tell which update exactly screws the things up.

@goldfire
Copy link
Owner

I've yet to reproduce this issue, do you have anymore specific steps or sample code to get it to happen? Also, is this with 1.1.x or 2.0?

@TheMaru
Copy link

TheMaru commented Dec 3, 2014

I got the same problem and I can at least help to clarify a bit why I have it.

The sound in question is looped. The variable node._pos in line 445 of howler.js v1.1.25 never gets set to 0 again so after some while the expression
duration = self._sprite[sprite][1] / 1000 - node._pos;
will be negative which results in the error "Error: Failed to execute 'start' on 'AudioBufferSourceNode': Duration must be a finite non-negative number: -36.6874"

The error of the first post in this thread comes right afterwards everytime you try to start the sound again

@TheMaru
Copy link

TheMaru commented Dec 3, 2014

Also it seems that the onend function won't be called after every restart of looping sounds but only the first time it restarts, maybe thats related to the node._pos not be reset to 0 again

@goldfire
Copy link
Owner

goldfire commented Feb 3, 2015

These issues should be fixed in the 2.0 branch, but please let me know if you are still seeing them.

@goldfire goldfire closed this as completed Feb 3, 2015
@goldfire goldfire added the 2.0 label Feb 3, 2015
@goldfire goldfire modified the milestone: 2.0 Sep 25, 2015
@arya-s
Copy link

arya-s commented May 25, 2016

I can reproduce this on mobile devices with a button that is used for playing/pausing audio. If I spam this button I get into these two states:

howler.min.js:2 Uncaught InvalidStateError: Failed to execute 'start' on 'AudioBufferSourceNode': The duration provided (-0.17) is less than the minimum bound (0).f @ howler.min.js:2t.play @ howler.min.js:2button.onclick @ lm_bundle.js?dc32441…:45935
howler.min.js:2 Uncaught InvalidStateError: Failed to execute 'stop' on 'AudioBufferSourceNode': cannot call stop without calling start first.

Here's a the code to reproduce this:

var sound   = new window.Howl({src: '/media/audio/accessible_uWSKjgX.mp3'});
var button  = document.createElement('button');
button.textContent = 'Play';
var playing = false;

button.onclick = function () {
   playing = !playing;

   if (playing) {
      sound.pause();
   } else {
      sound.play();
   }
};

sound.on('end', function () {
   playing = false;
 });

@goldfire
Copy link
Owner

@arya-s Can you give some more details on how you got that to happen including your testing environment? I setup the following fiddle and was unable to reproduce: https://jsfiddle.net/c9ezqbqj/.

@arya-s
Copy link

arya-s commented Jun 1, 2016

@goldfire it doesn't work with a fiddle, unless you know a way to disable zoom on double tap. You need to spam tap this button.

fabioelia added a commit to fabioelia/howler.js that referenced this issue Nov 10, 2016
goldfire#226

It seems as though AudioBufferSourceNode can get caught in cases where the seek and duration are negative 
"Failed to execute 'start' on 'AudioBufferSourceNode': The duration provided (-0.17) is less than the minimum bound (0)"

We can protect this by defaulting to 0 when we seek or set a duration below 0.
@fabioelia
Copy link
Contributor

Ran into the same issue on our application today.
Flooding the play action with numerous requests can lead to this problem, where the seek and duration can be returned as negative

@ofirgeller
Copy link
Contributor

Got this with version 2.0.2 (happened to a user).

Tried to replicate by spamming the play-stop button both on desktop and android.

Did not result in an error.

renawolford6 added a commit to renawolford6/howler-js that referenced this issue Nov 10, 2022
goldfire/howler.js#226

It seems as though AudioBufferSourceNode can get caught in cases where the seek and duration are negative 
"Failed to execute 'start' on 'AudioBufferSourceNode': The duration provided (-0.17) is less than the minimum bound (0)"

We can protect this by defaulting to 0 when we seek or set a duration below 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants