3 ms·
Enjoyable demo, but Chrome is suddenly taking high CPU when dropping sand and my laptop is sounding like a plane about to take off. Why are canvas demos always
by sgt 5y ago
Enjoyable demo, but Chrome is suddenly taking high CPU when dropping sand and my laptop is sounding like a plane about to take off. Why are canvas demos always so inefficient in the browser?
- usrn 5y agoThese are usually iterating over a screen-sized buffer every frame. There's no nice way to slice that, just a bunch of work for the machine to constantly do. EDIT: I'm out of quota. For games like this it's pretty hard. You can move it into a fragment shader or maybe mark certain rectangles in the canvas as "empty" (there's a very fast algorithm for cellular automata which pretty much has the same issue.) There are no "easy" solutions though.
- sgt 5y agoIs there a better way to build cute little canvas or browser games?
- 5560675260 5y agoOne simple improvement would have been to pause simulations as soon as system comes to rest.
- sgt 5y agoI was thinking - maybe JS is not the way to do this? Maybe to write similar things one should do it in WebAssembly. Thoughts? I mean, even with paused simulations, I don't see why an i7 CPU should be working at 100% just to draw something on a tiny window in a browser. It seems like a flaw in canvas and JS to me.