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

The web app uses too much CPU #29

Open
abcjjy opened this issue Apr 8, 2015 · 6 comments
Open

The web app uses too much CPU #29

abcjjy opened this issue Apr 8, 2015 · 6 comments
Labels

Comments

@abcjjy
Copy link

abcjjy commented Apr 8, 2015

I like the visualization and tooltips of this app. However, it the performance is not very well. On my mac book pro (chrome), it takes 100% cpu time. After turn off the "auto" option, it still takes 20-30% when idle. Can you fix this? Or simply port it to desktop? Or a mobile app?

@ttencate
Copy link
Owner

ttencate commented Apr 8, 2015

This is a legitimate issue; I've noticed it on my laptop as well. The problem is with the continuous rendering of the canvas element that draws the real-time spectrogram at the top. Even if I just clear it every frame without drawing anything, it still burns 100% CPU.

As a workaround, you can click that visualizer to disable it.

The real solution is probably to switch over to WebGL.

@ttencate ttencate added the bug label Apr 8, 2015
@marten
Copy link

marten commented Apr 8, 2015

Couldn't you stop the visualization automatically after (attack+sustain+decay) seconds?

@abcjjy
Copy link
Author

abcjjy commented Apr 9, 2015

I think the visualizer is a very important feature. And that is why I choose jfxr overother *fxrs.

According to my experience, WebGL is more performant than canvas. However, it still make the cpu burn if you always update it at 30 fps. Can you update visualizer only when sound is playing?

@ttencate
Copy link
Owner

ttencate commented Apr 9, 2015

Couldn't you stop the visualization automatically after (attack+sustain+decay) seconds?

There's a falloff after that, as it does some sort of IIR sliding average, but in principle, yes.

I just tried a very simple WebGL app. It also pulls CPU to 100%. Apparently this is normal. Blame your browser.

Meanwhile, I think I'll do what @marten said.

@mcanthony
Copy link

Canvas2D runs in GPU the same as WebGL so this will make no difference. Are we positive it is the visualizer causing "poor performance"? Your doing quite a lot of ScriptNode processing? or are you using AudioWorkers (if not then you will want to as SN will be deprecated) which will surely allow for faster rendering of the Audio. On my sluggish laptop with windows and too much running, it renders in 300ms usually and I consider that good. I will be playing with this project, feel free to hit me up if you want to get me up to speed.

@ttencate
Copy link
Owner

ttencate commented Jul 6, 2015

It's definitely the visualizer, because the high CPU disappears as soon as you turn it off.

Indeed render time for the sound effect itself isn't a huge problem. Longer sound effects (several seconds) do tend to make the UI a bit less responsive; that's tracked on #17.

(Offtopic - No ScriptNode processing is going on; the entire sample is pre-rendered into typed arrays. With ScriptProcessorNode it would be hard to refer to previous samples if they cross a buffer boundary.)

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

No branches or pull requests

4 participants