Remix.run Logo
rendaw 7 months ago

Not specific to leptos. My understanding is very rough, but rust's wasm-bindgen generates a javascript translation layer for the wasm. (Roughly) Javascript objects are stored in a lookup table and rust gets the handle (a number). Rust makes calls with that handle, which get translated back into javascript calls using the actual object. Similarly (I think) proxy objects are created for rust objects so javascript can call rust.

I was benchmarking some dom manipulation code and saw large GC pauses corresponding to the number of `element.classList` accesses I was doing from rust. I think the answer is that performance isn't great (compared to if browsers provided a wasm-native api that didn't have to go through javascript), but if you're doing a lot of calculation in rust or are writing a typically small UI it's not a significant cost... may be more important for graphics and visualization work.