Skip to content

embedded_asset! is broken on Windows Wasm builds #14246

Closed
@janhohenheim

Description

@janhohenheim

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

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()
        }
    );

Metadata

Metadata

Assignees

Labels

A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsO-WindowsSpecific to the Windows desktop operating systemP-CrashA sudden unexpected crashS-BlockedThis cannot move forward until something else changes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions