metafizzy / zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
https://zzz.dog
10.36k stars 393 forks source link

Would wasm make it any faster? #102

Open ryansupak2 opened 3 years ago

ryansupak2 commented 3 years ago

Sorry if this is a dumb question, and I browsed the source code and it looks pretty small and tight already. But would a WASM build of zdog make it faster or more performant?

desandro commented 3 years ago

Zdog source code is built to be run in the browser without compilation. It's designed to be a browser plugin — although in theory, it could be ported to other rendering engines.

As for WASM WebAssembly — I don't have any expertise here. Zdog is based on <canvas> which has a JS API. I'm not familiar with low-level shape rendering API that browsers use. I'm curious to here where any benefit could be.

ryansupak2 commented 3 years ago

Hi! I'm by no means an expert on this but I think the key advantage of WASM in this case is that it might make performance across browsers and platforms more consistently-optimal. If your JS is already super-tight (and I suspect it is), it probably won't make it much faster in the situations and platforms where it's already fast.

But: if there are some browsers or platforms where your JS underperforms, retooling it in something like AssemblyScript (which is a WASM compiler for TypeScript) might make it more consistently-fast:

https://www.youtube.com/watch?v=njt-Qzw0mVY&t=1375s

mootari commented 3 years ago

@ryansupak2 Why don't you start with a performance profile to find the actual bottlenecks, ideally in a way that can be replicated by others?