3 ms·
So much annoying truth there. The overhead of the WASM <-> JS bridge per call remains utterly insane, and this is the root of a lot of the pain. Whenever I fou
by fidotron 2y ago
So much annoying truth there.
The overhead of the WASM <-> JS bridge per call remains utterly insane, and this is the root of a lot of the pain. Whenever I found myself profiling it I start thinking I'm missing something, then found that this is what everyone learns the hard way. This is why I have yet to deploy anything that does much WASM physics, since physics engines generate a lot of callbacks by default. (I spent a lot of my life dealing with things like the JNI or early Unity, and nothing compares to the WASM overhead at all).
The timing "for security" drives me insane too, especially how different it is across browsers.
I resorted to having a worker that does everything except make the actual web API calls, and that's what is going on at https://luduxia.com/whichwayround https://luduxia.com/whichwayround
- samiv 2y agoActually in my experience running physics (Box2D) is relatively harmless since it's purely in WASM and doesn't need to interact with any JS API directly. By far the biggest headache for me is actually Lua. It has terrible perf natively also but in WASM it's complete dog shit. I suspect there might be some bad allocation patterns or something that make it perform very poorly. I haven't had time to investigate that yet to my satisfaction. Your game runs quite smoothly, didn't get the logic but it didn't jank much. :)
- fidotron 2y ago> Actually in my experience running physics (Box2D) is relatively harmless since it's purely in WASM and doesn't need to interact with any JS API directly. I see! In my case the actual scene graph is in JS too, and I've seen enough people struggle with both approaches to wonder which one really comes out ahead in the end. > Your game runs quite smoothly, didn't get the logic but it didn't jank much. :) Good! These assets here are not remotely optimal, but the core loop going on is not too bad given the complexity of what it can through around before having problems. The whole separate worker thing introduces inevitable continuous timing problems, but I've seen too many webgl games where they run perfectly smoothly for a bit, then stutter like hell, and repeat. It's got to be GC gunk.
- samiv 2y agoHere's an example of running Box2D physics in WASM https://ensisoft.com/demos/playground/game.html https://ensisoft.com/demos/playground/game.html Still very small scenes of course so not much stuff going on. Yes, the GC pauses are a known issue in Lua.