goldfire / howler.js

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

Memory leak on unload() method #914

Closed ogomez92 closed 6 years ago

ogomez92 commented 6 years ago

There seems to be a leak on the unload() method. I have tested on Chromium (haven't had the chance to test on other browsers), but calling unload and then checking the state reports that the sound is unloaded. However, ram does not get freed and all the sounds related to it have been unloaded (i.e. coppies of the same sound).

I am not sure whether this is a bug in Howler or in Chromium, but I'm posting this out here in case someone has experienced anything similar?

Thank you.

rfmneves commented 6 years ago

I'm having the same issue. Having some sound sprites loaded and then reloading the page. RAM size keeps increasing due to sounds. If you call Howler.unload(), all howls go to unloaded state, context is destroyed and gets recreated on unload as expected. Problem is the resources aren't getting released. Even if you trigger garbage collector on chrome tools. Is there any workaround or am I missing something?

Thanks

ogomez92 commented 6 years ago

The reason is Chrome < 61. Chrome61 was a big update. Electron 1 is based on Chrome 59. You need to get Electron 2 beta.

On 3/1/18, Ricardo Neves notifications@github.com wrote:

I'm having the same issue. Having some sound sprites loaded and then reloading the page. RAM size keeps increasing due to sounds. If you call Howler.unload(), all howls go to unloaded state, context is destroyed and gets recreated on unload as expected. Problem is the resources aren't getting released. Even if you trigger garbage collector on chrome tools. Is there any workaround or am I missing something?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/goldfire/howler.js/issues/914#issuecomment-369551166

rfmneves commented 6 years ago

I'm getting this issue on Chrome Version 64.0.3282.186 (Official Build) (64-bit) mac. Can you elaborate your answer please?

ogomez92 commented 6 years ago

Well, in my case it got fixed by upgrading to electron 2 beta. If it didn't fix it for you then it might be a howler problem or more likely a problem on Chromium.

Hth.

On 3/1/18, Ricardo Neves notifications@github.com wrote:

I'm getting this issue on Chrome Version 64.0.3282.186 (Official Build) (64-bit). Can you elaborate your answer please?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/goldfire/howler.js/issues/914#issuecomment-369557032

Saltallica commented 6 years ago

+1 Same issue here on latest Chrome 64.0.3282.186 (64-bit)

Ghorthalon commented 6 years ago

Can we confirm that this is a Howler bug and not Chrome? I also don't get this problem in Electron 2 beta, which seems to update to Chromium 61. Maybe this is a Chrome issue and should be brought up with the Chromium team? I've seen several issues regarding this on the Chromium bug tracker but they all seem to have been abandoned. Nobody uses WebAudio?

rfmneves commented 6 years ago

If you try Howler sound sprite example couple of times and reload the page you'll see memory used by the tab isn't cleared at all. I'm suspecting the decoded buffers aren't clear at all even if you call unload methods from Howl or Howler. Doing the same on createJS sprite example and waudjs we get the same behavior. I would say it's a chrome issue but it would be very helpful to get some other insights on this

j0rdsta commented 6 years ago

I suspect @rfmneves is right. In recent times I've encountered a strange error where I've been unable to play sound on a web page with Howler due to an error saying there's too many AudioContexts open (even though there should only be the one initialised by Howler). Opening the web page in a new browser tab seems to fix the issue.

Saltallica commented 6 years ago

Looks like there are a number of issues with Chrome's implementation of Web Audio:

[Meta] WebAudio memory leak issues (GC)

And they haven't been addressed in over a year 👎

skepticalmartyr commented 6 years ago

Just upgraded to the latest version of Chrome - 65.0.3325.146. I'm not seeing the issue anymore. Memory gets freed as expected when the page reloads.

GeKorm commented 6 years ago

Just tested Firefox for a whole day and there doesn't appear to be any memory problems. Must be Chrome then.

goldfire commented 6 years ago

I'm fairly certain this is an issue with Chrome. We've been seeing a lot of memory related issues in Chrome on our games lately, and not just with audio. I'm going to close this for now, but will reopen if someone is able to confirm there is a howler-specific issue here.

richiedevs commented 3 years ago

I myself also experience this issue, using electron v11.1.1, which uses chromium, strange how the chromium havent fixed the issue for 2 years

krist7599555 commented 3 years ago

2021 also have this problem on mobile (both safari and chrome)

robinfriedli commented 1 year ago

I currently have the same issue in Chrome, Firefox and Safari. Playing more sounds steadily increases the process' memory footprint despite calling unload() on the previous Howler instance each time. Using html5: true fixes this and since I actually prefer streaming the audio might be any size I'll opt for that. It'd still be nice if someone could revisit this, I doubt I'm doing something wrong on my end because html5: true fixes the problem immediately, so either various browsers still have problems with the web audio API or there's an actual issue in howler.