3 ms·
I'm developing a wasm game, and currently I am targeting WebGL2 in order to run in iOS Safari. Me (and others, I'm sure) are currently waiting for WebGPU [1] t
by shzhdbi09gv8ioi 3y ago
I'm developing a wasm game, and currently I am targeting WebGL2 in order to run in iOS Safari.
Me (and others, I'm sure) are currently waiting for WebGPU [1] to land in Safari so it will make sense to target it.
WebGPU allows for simplified porting of desktop games to the web, such as WGSL shaders [2]
WebGPU will be the next big thing [3], and currently it is enabled on Chrome Windows/macOS, and can be enabled in Firefox Nightly with a config setting.
There's also an issue with limited language support. For example golang still has some stuff left to stabilize around the WASI, and the resulting binaries are rather large.
In rust, things look better. I can compile a release of my game to about 8MB .wasm file, which gzipped sits at around 3MB. Most other tooling I have looked at produces far larger wasm binaries, which makes it a no-go for mobile apps.
Hopefully, 2024 will be the year of WebGPU!
1: https://caniuse.com/?search=webgpu https://caniuse.com/?search=webgpu
2: https://www.w3.org/TR/WGSL/ https://www.w3.org/TR/WGSL/
3: https://github.com/gpuweb/gpuweb/wiki/Implementation-Status https://github.com/gpuweb/gpuweb/wiki/Implementation-Status
- speps 3y ago8MB seems high for Rust. Even the project I did [1] which was using D (with GC) ended up with an 8MB WASM. Rust's WASM target is much more exercised than D's, so I think you might need to tweak some compile options. [1] https://github.com/speps/tt https://github.com/speps/tt
- BD103 3y agoRust binaries seem to be larger than they should be, though. I believe Kobzol [1] has been making some work on that. [1]: https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-binaries-smaller-by-default.html https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-b...
- lesuorac 3y ago(Not op) I agree that 8MB seems high. I can generate a 6MB binary using `--debug` with `wasm-pack` so definitely for a more complex thing I could see 8MB. I think `--release`, `codegen-units = 1`, `opt-level = 3/z` are the three biggest things that affect binary size for me. I don't think 8MB is that big a deal for a web game though. Like how large are the images? If you're going to dynamically load in like 50+ MB of assets then having an initial game of 8 MB is the small pole in the tent. I have my stuff setup as a PWA so once everything has been downloaded it takes 0 MB on the wire to open a second time; you could set-up the game as 2 binaries; one super-small one that just basically handles an opening cinematic and a larger one that can actually play the game which is downloaded while the cinematic plays (or is cached in future opens).
- shzhdbi09gv8ioi 3y agoThat's possible. I did spend quite a bit of time tinkering with compiler flags and followed the recommendations, but there is many knobs. For what it's worth I don't think 3MB is extremely large anymore, as several popular websites already weight in 2-3 MB for a full page loads. Examples: * www.youtube.com = 3.3 MB * www.tiktok.com = 3.3 MB * www.instagram.com = 2.1 MB (according to https://www.supermonitoring.com/p/page-speed https://www.supermonitoring.com/p/page-speed) That said, I would love to shave off more size off my wasm binaries :-) Some notes I found just now seems to be in line with my results, though: https://github.com/bevyengine/bevy/issues/3978#issuecomment-1044333040 https://github.com/bevyengine/bevy/issues/3978#issuecomment-...
- shzhdbi09gv8ioi 3y agoFWIW, this is my relevant Cargo.toml settings: [profile.release] lto = "fat" codegen-units = 1 opt-level = 3 debug = false panic = "abort" strip = "debuginfo" [profile.wasm-release] inherits = "release" opt-level = "z"