Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssetServer.watch_for_changes() must be called before creating window #3627

Closed
jakobhellermann opened this issue Jan 10, 2022 · 6 comments
Closed
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior

Comments

@jakobhellermann
Copy link
Contributor

jakobhellermann commented Jan 10, 2022

For some reason, calling watch_for_changes in a setup function will not register file events in the future, while doing it before starting the app will.

The exact point at which it breaks is winit::WindowBuilder::build, call watch_for_changes before and it will work, call it after and it won't.

Tested on linux with x11 and wayland, will try windows later.

@jakobhellermann jakobhellermann added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels Jan 10, 2022
@mockersf
Copy link
Member

Example hot_asset_reloading which does that is working for me on macOS.

Were you able to reproduce on windows?

@johanhelsing
Copy link
Contributor

The hot_asset_reloading example works for me on windows 10. Shaders don't reload, though, but I'm guessing that's unrelated?

@johanhelsing
Copy link
Contributor

Works on linux for me as well (tested v0.6.0 tag and main)

@gajop
Copy link
Contributor

gajop commented Aug 20, 2022

I can confirm multiple issues with shader hotreload:

  • Bevy's official post_processing.rs example doesn't reload shaders for me.
  • adding it in one of my code's startup system has no effect (shaders don't reload)
asset_server.watch_for_changes().unwrap();
  • inserting it as a resouce after I've added my other plugins didn't work
    App::new()
        .add_plugins(DefaultPlugins)
        .insert_resource(AssetServerSettings { // does NOT work
            watch_for_changes: true,
            ..default()
        })
        // other stuff
        .add_startup_system(setup)
        .add_system(some_system)
        .run();

Thankfully due to insight from this issue I figured I should put this at the top of my program, something like:

    App::new()
        .insert_resource(AssetServerSettings { // Works
            watch_for_changes: true,
            ..default()
        })
        .add_plugins(DefaultPlugins)
        // other stuff
        .add_startup_system(setup)
        .add_system(some_system)
        .run();

@mwbryant
Copy link
Contributor

Someone on the discord also noted using asset_server.watch_for_changes().unwrap() anywhere in the app will break this workaround.

@jakobhellermann
Copy link
Contributor Author

Fixed by removing the watch_for_changes method: #5968

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

5 participants