bevyengine / bevy

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

iOS WASM out of memory error - asset loading #12921

Open v-kat opened 7 months ago

v-kat commented 7 months ago

Bevy version

0.13.1

AdapterInfo { name: "Apple GPU", vendor: 4203, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }

iOS 17.2

Loading 10 larger images quickly with asset_server.load(format!("tester{}.webp", x)); on iOS web causes: 317829886-81be22d5-7943-4ea4-a5b8-b9901db5d7a3

https://github.com/v-kat/bevy_bad_render_bug_repo has a reproduction

Also see https://github.com/bevyengine/bevy/discussions/12678#discussioncomment-9076015

SolarLiner commented 7 months ago

Tagging as both iOS and Web, but something tells me this is reproducible on all OSes, as it looks like a problem with WASM memory management.

alice-i-cecile commented 6 months ago

A commercial app (Cult) encountered this. You need to be careful to load your assets sequentially unfortunately due to limitations in WASM's memory management.

alice-i-cecile commented 6 months ago

More discussion about workarounds here. #12653 discusses adding an example for this. https://github.com/WebAssembly/design/issues/1397 discusses this problem more broadly.

v-kat commented 6 months ago

A commercial app (Cult) encountered this. You need to be careful to load your assets sequentially unfortunately due to limitations in WASM's memory management.

Can this be made the default behavior on WASM builds (loading assets sequentially)? I don't see how this would ever be desirable otherwise. It seems like there's maybe something wrong with the asset loading on web wasm otherwise e.g. memory leak or other parallelism issue. My example explicitly involves low amounts of memory and loading and still triggers the problem.

alice-i-cecile commented 6 months ago

Yep, I think that's a good next step.