Description
Bevy version
0.14.0
Relevant system information
rustc --version
:rustc 1.81.0-nightly (6292b2af6 2024-07-02)
- Running Windows 11
`AdapterInfo { name: "NVIDIA GeForce GTX 1080 Ti", vendor: 4318, device: 6918, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.99", backend: Vulkan }`
What you did
There's a minimal reproduction here: https://github.com/janhohenheim/asset-crash
The relevant code is just this main.rs
:
use bevy::{asset::embedded_asset, prelude::*};
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins);
embedded_asset!(app, "splash.png");
app.run();
}
The setup is:
- crate
- src/
main.rs
splash.png
- src/
What went wrong
Running this with cargo run
works.
Running it on Wasm on Windows instead gives me:
Failed to find src_prefix "src" in "src\\screen\\splash\\mod.rs"
This is the part of the Bevy code that panics: https://github.com/bevyengine/bevy/blob/main/crates/bevy_asset/src/io/embedded/mod.rs#L141
And this is the PR that introduced it: #10383
Note that this is not reproducible on Linux
Additional information
The minimal example has a workaround. Move crate/src/splash.png
into crate/assets/splash.png
and embed it with embedded_asset!(app, "../assets/splash.png");
.
For reasons unknown to me, doing the same workaround on https://github.com/TheBevyFlock/bevy-template does not work.
I also tried running the embedded assets example with cargo build --example ...
and that one works.
Using load_internal_binary_asset
like this works as well:
load_internal_binary_asset!(
app,
SPLASH_IMAGE_HANDLE,
"splash.png",
|bytes, _path: String| {
Image::from_buffer(
bytes,
ImageType::Extension("png"),
default(),
true,
ImageSampler::linear(),
RenderAssetUsages::RENDER_WORLD | RenderAssetUsages::MAIN_WORLD,
)
.unwrap()
}
);