Pros and Cons #24
Replies: 1 comment 4 replies
-
thanks for the feedback 🙂 this is helpful, and it's consistent with what I suspected.
yes, agreed. documentation could help, but requires an expert — this is a machine port, so I built this without really understanding how to use it or how it itself works. yes, the I think that completing a project with this library requires persistence — I'm not sure whether there's a cohort of users who "could succeed, with just a bit more investment in docs". I think that to serve those users, we'd need another library that wraps this project with opinionated, JS-idiomatic APIs (maybe like Planck's APIs?) and has a focus on providing documentation and examples. whereas my aim here has been to provide just the axioms, in a sustainable way — this project can react pretty easily to upstream changes in Box2D, which (as you've noticed) enabled it to incorporate liquidfun without major rewrites.
yeah, I think I'm noticing that too. I didn't get performance anything like the asm release, and I'm not sure whether it's because my demo world is different, or if it's something the library needs to approach differently. certainly, liquidfun's asm release paid special consideration to "how do we create performant JS bindings to the ASM code" and "can we use our knowledge of the memory layout, to lookup values without making another call into ASM": I figured I may not need tricks like that, since browser performance considerations of JS->WASM calls are different nowadays. moreover, the demo that I tried makes almost no calls into WASM:
moreover, I thought the box2d-wasm distribution would have a few advantages because it:
perhaps none of these assumptions are incorrect. the reason I'm worried that my own demo isn't a fair comparison, is because (unlike most of lfjs's demos), my particles don't stay together (perhaps this prevents optimizations? does lfjs clump nearby particles into bigger objects?) and they frequently stray far away, expire and respawn (would this cause an allocation?). the slowdown I see is a stutter, which almost suggests garbage collection… but that'd surprise me — Box2D/liquidfun's memory allocation is very careful to re-use old memory rather than malloc()/free()ing. maybe the stutter is heap growth? perhaps I just need to ask for a large heap to start with? it's also possible that I've created a b2ParticleSystemDef with really challenging parameters. if you're able at all to share the code of your project, I'd be interested to see which APIs you're invoking (especially in the main loop), and see whether there's any obvious ways to avoid allocations, re-use memory, or avoid WASM calls. |
Beta Was this translation helpful? Give feedback.
-
This is now the third box2d+liquidfun library that I've tried. The original liquidfun asm release is great but lacked many features of the original liquidfun library, such as adding particles to existing groups or joining groups, and it has a glaring bug that doesn't allow you to create a single particle via CreateParticle(); you can only create groups. (It will add it, but the particle just freezes and never updates)
Another port I tried was flyover's box2d js port with liquid fun, which is awesome because it's very easy to use and all code is exposed, but it's not asm or wasm, just pure js, so it was too slow.
This Box2d-wasm port is exciting because it includes soooo many more features of liquidfun previously unavailable, but it still has some major cons.
Pros:
Cons:
Overall I'm very impressed with this fork, and based on the Issue request, you did it quickly!
Beta Was this translation helpful? Give feedback.
All reactions