views:

187

answers:

3

I'm checking out the nightly builds of Firefox and Chromium with support of WebGL with a few demos and tutorials and I can't help but wonder about the extremely high CPU load they cause.

A simple demo like this one runs at a sustained 60% of my dual core. The large version of this one maxes out the CPU to 100% and has some visible frame loss.
Chromium seems to be slightly better than firefox but not by much. I'm pretty sure that if these were desktop application the CPU load would be negligible.

So what's going on here? what is it doing? Running the simple scripts of these can't be that demanding. Is it the extra layer of security or something?


Edit: I found the original demo which was porded to webgl here: http://rrrola.wz.cz/files/puls_win.zip

Running this (on full screen) gets the CPU to a sustained 48% so maybe I was wrong...

A: 

Graphics rendering is extremely CPU intensive, that's why there are video cards with GPU's so that work can be off loaded to them instead. I'll try out your demos and see how they go on my computer which does have a decent video card installed.

Khorkrak
This computer has an nVidia 8600 which is more than capable of handling these.
shoosh
ok not going to do that again LOL. My poor video card's GPU was heading for a melt down. So yeah WebGL is still a work in progress and lets just say much more optimization is needed. btw my cpu's weren't being hammered much at all. I'm using an nVidia 7900GS so I guess it's time for an upgrade :(
Khorkrak
+1  A: 

Can't repro the performance issue. The first runs at 98-100fps using just under one core of my Core i5. The second uses about 50% of one core.

This is with Chrome dev channel, Windows 7 64-bit, Radeon HD 5770, in other words a moderately powerful modern machine.

Also note that a small code size doesn't equate to fast, when there's a lot of iteration (and these demos appear to have a lot of polygons).

Ben Voigt
Don't you find it strange it is using a full core to do basically a whole lot of nothing?
shoosh
+2  A: 

It is indeed true that webgl is slow. Becuase it is new, it uses a software compositor. So it is basicly does GPU - CPU - GPU calls for just one frame. Both firefox and webkit are working on it

EWGL
I'll second what EWGL says here. The WebGL spec requires that the rendered 3D canvas can be composited with the other HTML elements on the page (eg. so that text can appear on top of it). This means that the GPU renders the scene, then the CPU gets a copy and combines it with the rendered HTML, which is then sent back to the graphics card to display. So, GPU-CPU-GPU on every frame; this is expensive. The browser writer are fixing the problem -- IIUC in the future, the GPU will do the compositing.
Giles Thomas