[HTML5] Sound.play() throwing error after switching browser tabs

A very reproducible crash, tested on Chrome and Firefox.
We play music files (ogg & mp3, the format doesn’t matter). The code is as simple as:

snd.play(0.0, 0);

After the project is loaded, the sounds will play fine, unless another browser tab is opened and the project tab left inactive for 10-20 seconds. Then, after returning to the project and clicking something that makes sound, the following error will occur:
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable

Stack trace:

pause [http://localhost:2000/lib/howler.min.js:2:10497](http://localhost:2000/lib/howler.min.js)
e [http://localhost:2000/lib/howler.min.js:4:9171](http://localhost:2000/lib/howler.min.js)
Howl.prototype.pos [http://localhost:2000/lib/howler.min.js:4:3754](http://localhost:2000/lib/howler.min.js)
setPosition [HTML5AudioSource.hx:307:78](file:///D:/Haxe/haxe/lib/lime/7,1,1/src/lime/_internal/backend/html5/HTML5AudioSource.hx)
play [HTML5AudioSource.hx:72:2](file:///D:/Haxe/haxe/lib/lime/7,1,1/src/lime/_internal/backend/html5/HTML5AudioSource.hx)
play [AudioSource.hx:71:2](file:///D:/Haxe/haxe/lib/lime/7,1,1/src/lime/media/AudioSource.hx) 
openfl_media_SoundChannel [SoundChannel.hx:107:3](file:///D:/Haxe/haxe/lib/openfl/8,6,4/src/openfl/media/SoundChannel.hx)
play [Sound.hx:509:9](file:///D:/Haxe/haxe/lib/openfl/8,6,4/src/openfl/media/Sound.hx)

If any additional info is needed (or the link to the project), I’ll gladly provide :slight_smile:

What version of Lime are you using? I wonder if its possible that a newer version of Howler resolves this

https://github.com/goldfire/howler.js/commits/master

Lime 7.1.1.

Yes, the people are complaining about these errors on the project page: https://github.com/goldfire/howler.js/issues/1067

Howler’s dist folder still contains the 2-month-ago version, so I downloaded howler.core.js from /src and tested it against howler.min.js. No errors so far!
Thanks for your advice!

1 Like