bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Too large WebAssembly bin file

Open Wandalen opened this issue 3 years ago • 4 comments
trafficstars

What problem does this solve or what need does it fill?

Trivial example 2d_rect weights 13MB.

image

Playing with optimization options I reached ~4 MB. Still that's too much. Is that possible to get less than 0.5 MB?

What solution would you like?

Excluding some features? Putting naga under a feature? More features?

Wandalen avatar Jan 29 '22 18:01 Wandalen

You may want to try using this

[dependencies.bevy]
version = "0.6"
default-features = false
features = [
  "bevy_sprite",
  "bevy_render"
]

in your cargo manifest.

This will remove all the "bloat" from bevy and should optimize size of the binary.

heavyrain266 avatar Jan 29 '22 18:01 heavyrain266

Also for the size over the network: gzip makes a huge difference (something like 14mb -> 3-4mb). You can also try removing debug info and running wasm-opt: https://rustwasm.github.io/book/reference/code-size.html

jakobhellermann avatar Jan 29 '22 19:01 jakobhellermann

https://github.com/WebAssembly/binaryen is the current state of the art to optimise wasm.

The example page is using a release build without extra optimisations and the same features for all examples, so it can't be reduced to a minimal set. Luckily it's hosted by GitHub with a properly configured host for compression, and a CDN.

mockersf avatar Jan 29 '22 19:01 mockersf

https://github.com/bevyengine/bevy/discussions/14864

cart avatar Aug 22 '24 02:08 cart