Stopping a non streaming sound just before disposing it throws in Safari

This might not be very urgent as you can just, don’t stop the sound before disposing it, but thought it was good to report never the less.

The exception that you get is InvalidStateError: The object is in an invalid state and here is a playground with the repro link. This exception is thrown (only in Safari) if you call stop() twice on an AudioBufferSourceNode. The reason why this might be called twice is because the property this.isPlaying is updated asynchronously after the first stop, and a dispose will try to stop the sound again.

I don’t think this is urgent and feel free to close it but I just wanted to point this out as Safari is not the most common browser and this might lead to other types of bugs if you are not expecting a throw when disposing a sound.

You’re right, here’s a PR that should fix the problem:

2 Likes

Great, thanks for the quick fix!