Music randomly stops working

I have recently made a version of forsteken's tetris project with the gameboy sounds, but after some time playing it the music glitches out. Here it the project:

Can someone help find out what is going on and how I can fix it?

How much time does it normally take to fail?

Also, maybe add some waits inside your forever loops so your not unnecessarily using CPU processing time that might be contributing to your issue
e.g.
image

I played a whole game, and the music didn't stop.

(Great game, by the way--I couldn't stop playing it!)

The music stops around 2 minutes with and without the wait 0.5 block.
It is probably just my computer though.

Is it an iOS system?

It's an old - ish dell laptop.

In that case IDK what might be the cause. :slightly_frowning_face:

There's a problem where sounds create DOM nodes that are never deleted. DOM nodes can create more lag the more you create more DOM nodes. As a result, after about 600-800 sounds played (600-800 DOM nodes) can create massive lag for sounds, glitching sounds. Also, after 1,000 DOM nodes played, the sound stops working.

Is there a way to create less DOM nodes?

(offtopic) your logo looks very similar to mine.

image

sladescar - YouTube

The workaround is to use this:

It does not consume DOM nodes so playing it thousands of times won't corrupt the sound.

thanks

Thank's for this : I confirm there's a bug in the play sound block but not in the play sound at xx Hz block...

Maybe BH or Jens can look at this...

this is a pretty well known browser issue. In the past I've managed to work around it every now and then, but recently browsers have become so memory greedy and yet aggressively possessive of DOM nodes that I'm running out of ideas.

(@all: If you have a good idea or experience in this, I'm open to suggestions, but please only chime in if you actually know something, don't tell me to "just free the memory or delete the DOM node again once the sound stops". Tnx)

can't you just make the play sound block the play sound at Hz block with the sample rate of the sound?

and none of yall have z in your usernames

yeah, I didnt think of that

Come on, folks … don’t be a snowflake. Why flag @jens for being himself? Without him Snap! wouldn’t exist, and neither would this forum - he absolutely deserves some credit here. A little sarcasm now and then must be his way to cope with ignorance, cheekiness, and JavaScript. His legendary rants are a main attraction of this forum, and ought to be recognized as intangible cultural heritage.

:fire_extinguisher::dash: