3 ms·
Nice demo. Is there any reason why every WebGL demo makes my browser burn the CPUs and drain the battery? Equivalent native code that produces output of the sam
by 4ad 12y ago
Nice demo. Is there any reason why every WebGL demo makes my browser burn the CPUs and drain the battery? Equivalent native code that produces output of the same quality does not have this much of an effect.
- tux3 12y agoIf web sites were allowed to execute native code on your computer, this would be a huge security risk. Instead we have more restricted web languages, but at the cost of performance. Basically.
- 4ad 12y agoWell, first, even assuming JITing JavaScript is expensive and produces expensive code, shouldn't WebGL demos mostly stress the GPU and not the CPU? Second, web sites are not allowed to execute native code, but all the modern JavaScript engines compile down to native code. My intuition tells me to expect the performance of compiled JavaScript to be low, however I have seen endless benchmarks that say that's not the case and JITed JavaScript should be plenty fast. However I feel this disconnect between those benchmarks and reality. The benchmarks say it's fast, while in fact I perceive it to be pretty slow and a resource hog.
- mixedbit 12y agoThis isn't the case with every WebGL demo, only animations need to continuously render. For example WebGL apps that change view only when camera position changes do not require to continuously invoke the render loop and often can have low CPU requirements.
- flohofwoe 12y agoIt depends I think. There isn't any built-in reason why WebGL code would drain batteries faster then a similar native-code demo. WebGL has to do a bit more validation on the CPU which may contribute a bit. But other then that most demos should be very light on the CPU side, so the difference between JS and native code wouldn't be an issue. However, many WebGL demos move a lot of work to the GPU (especially the shadertoy demos, which render the entire scene in a single fullscreen quad and have absurdly complex pixel shaders), epecially in fullscreen mode these would suck your battery dry very quickly. On my fairly old MBP, all fullscreen 3D apps (also native games) kick the fan into high gear immediately and the bottom gets warm very quickly, while most "reasonable" WebGL demos don't have this effect (e.g. some of the lighter ones from here: http://alteredqualia.com/ http://alteredqualia.com/)