Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get this to work nowadays? #12

Open
ghost opened this issue Jun 3, 2014 · 12 comments
Open

How to get this to work nowadays? #12

ghost opened this issue Jun 3, 2014 · 12 comments

Comments

@ghost
Copy link

ghost commented Jun 3, 2014

I'm getting many kinds of javascript errors on Chrome and Firefox, does anyone know how to get it compatible with today's browser?
Thanks

@ccorcos
Copy link

ccorcos commented Dec 8, 2014

I've been messing around with it, but I'm getting all kinds of memory leaks i think...

https://github.com/ccorcos/meteor-webaudio

@ghost ghost closed this as completed Dec 8, 2014
@ghost ghost reopened this Dec 8, 2014
@ghost
Copy link
Author

ghost commented Dec 8, 2014

Interesting code, did you try profiling the memory using Google Chrome to find what and where it leaks?

@ccorcos
Copy link

ccorcos commented Dec 8, 2014

I tried it, but I couldn't find out where the leaks are. I've never done that before and its very hard to figure out.

@ghost
Copy link
Author

ghost commented Dec 9, 2014

What's your development setup to run that code?

@ccorcos
Copy link

ccorcos commented Dec 17, 2014

I'm using meteor there. But meteor is entirely unnecessary here. I copied it all to a just an html document and its still a problem for me.

@ccorcos
Copy link

ccorcos commented Dec 17, 2014

I'll upload it so you can see it

@ccorcos
Copy link

ccorcos commented Dec 17, 2014

Here it is with just static files (no dev environment). Thanks for the help. I'm really interested in how you inspect this. Its frustrating how there are no console errors...

https://github.com/ccorcos/meteor-webaudio/tree/html

@ghost
Copy link
Author

ghost commented Dec 24, 2014

I was able to get it stable as far as of memory usage goes, it would stick to a certain amount of RAM and then would go up 100kb to 300kb but then the garbage collection would kill some of those bytes returning to the old amount. The only problem that I found is that sometimes onaudioprocess stops working, reloading the page a few times fixes it.

What I did was to dump the temporary canvas:

HERE:
ctx = canvas.getContext("2d");
//tempCanvas = document.createElement("canvas");
//tempCtx = tempCanvas.getContext("2d");
canvas.width = width;
canvas.height = height;
//tempCanvas.width = width;
//tempCanvas.height = height;

AND HERE:
drawSpectrogram = function() {
try
{
var i, j, sp, value, _i, _j, _ref;
//tempCtx.drawImage(ctx.canvas, 0, 0, width, height);

AND HERE REPLACED WITH THE DEFAULT CANVAS:
//ctx.drawImage(tempCanvas, 0, 0, width, height, 0, 1, width, height);
ctx.drawImage(ctx.canvas, 0, 0, width, height, 0, 1, width, height);

@ghost
Copy link
Author

ghost commented Dec 24, 2014

I also made the pause function to freeze the drawing:

if (!paused)
{
requestAnimationFrame(drawSpectrogram);
}

@ghost
Copy link
Author

ghost commented Dec 24, 2014

Interesting finding, on Firefox it never freezes but the memory usage is huge and keeps growing.

@ccorcos
Copy link

ccorcos commented Dec 29, 2014

yeah. I can't seem to figure out what is going on. I just quit and used audio context analyser node instead. but it definitely doesnt have a lot of the conveniences that they have here....

@ghost
Copy link
Author

ghost commented Dec 29, 2014

The leak seems to be on the canvas drawing portion (requestAnimationFrame), at least on Chrome that's what I confirmed and after the changes above I got to a stable ram usage, I think it was around 27MB. On Firefox I didn't have a change to find what leaks yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant