goldfire / howler.js

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

Simultaneous loops get distorted and choppy after a couple hours #1694

Closed alana314 closed 7 months ago

alana314 commented 7 months ago

The Problem

I have several wavs on loop playing with howler and using fades to crossfade between them. Howler does a good job of restarting the loops seamlessly and at the exact same time. I was using as many as 32 but eventually when running for an hour or two, the audio got choppy and distorted. I lowered it to 12 loops but it still happens after 2 hours. A refresh of the webpage fixes it.

Reproducible Example

No response

Reproduction Steps

Start loops with:

day1am0lull.play()
            day1am1low.play()
            day1am2med.play()
            day1am3high.play()
            day1pm0lull.play()
            day1pm1low.play()
            day1pm2med.play()
            day1pm3high.play()
            day1eve0lull.play()
            day1eve1low.play()
            day1eve2med.play()
            day1eve3high.play()

fade them individually or together with sound.fade(sound.volume(), 1, transitionLength * 1000) The google chrome tab only seems to use 231MB, but starts stuttering after 2 hours. Is there a memory leak with loops? I'm also using websockets to trigger the fades.

Possible Solution

No response

Context

I'm using howler to provide background music for an installation with different states throughout the day.

Howler.js Version

v2.2.4

Affected Browser(s)/Versiuon(s)

Chrome 118.0

alana314 commented 7 months ago

I may be wrong about this being a memory leak, I set the tab in chrome's performance settings to never sleep and it's working better, though it still does glitch occasionally after an hour or two.

alana314 commented 7 months ago

I believe I've tracked this down to a chrome web audio memory leak bug with linearRampToValueAtTime, which Howler uses. Running it in firefox works fine. https://bugs.chromium.org/p/chromium/issues/detail?id=166853