bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.15k stars 3.57k forks source link

Removing image crate from wasm builds #13247

Open valaphee opened 6 months ago

valaphee commented 6 months ago

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

There is no need for a full-on image parsing library on wasm builds, as the user agent integrates plenty of image parser. It's also possible to directly initialize images from such sources. Either through HTMLImageElement or ImageData.

This would improve the loading times, by removing the image parser running in wasm, and the delivery time of the wasm file itself, as I assume that the image crate itself is quite heavy.

This is also needed for video support on Web, as there is not really any other option. Any sort of software encoding would be probably too slow or cost a lot cpu.

What solution would you like?

Switching over to using HTMLImageElement, but this would require to somehow prevent the AssetServer from fetching, and the AssetLoader getting the full url to create an HTMLImageElement which is handed over to wgpu.

What alternative(s) have you considered?

Additional context

Requires https://github.com/gfx-rs/wgpu/pull/5668

mnmaita commented 2 months ago

Looks like https://github.com/gfx-rs/wgpu/pull/5668 got merged