fenster
fenster copied to clipboard
Add webassembly support.
It would be fantastic to include webassembly support.
Today I use Go to do the things this library does but writing it in C would produce a much smaller binary and be much smoother for users to download.
Bonus points 😁
- Without Emscripten.
- WebGL instead of 2D canvas for better performance.
I would also like wasm-support, but I disagree with your bonus-points
- Emscripten, especially nowadays, does a decent job of making light wasm, especially with
WASM=1. the alternative would be to implement all of our own memory-management and hooks back to canvas. Other little gotchas exist, like stdio. you need to implement all that yourself (and make hooks in the host) or use something like wasi-sdk, which assumes the host will have a specific shape of imports (WASI) but the outputted WASM ends up a little less optimized, and you still need the host functions (I know because I made a browser host WASI.) I don't really see the point of this, even though I often avoid emscripten, especially when doing non-web stuff that doesn't need IO or web things, but I think it will just mean more work that needs to be done here, without any real payoff. - have you done speed tests with a 2D canvas on webgl? the speed is actually a bit better in my testing, with 2D canvas for a framebuffer, on web. it's also a more "regular way" to do a 2D canvas on the web. it seems a bit silly to setup a 2D canvas shader, and copy memory in/out of the GPU manually, when the browser already does this better, for you.
Anyway, I made a PR that does 2D canvas with imagedata. I think it's probly about as good as you will get, in terms of performance.