bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Hot asset reloading example does not update when saving torus.gltf

Open Anti-Alias opened this issue 1 year ago • 7 comments

Bevy version

0.14.1

Relevant system information

Tested on:

  • Windows 10
  • Linux (Ubuntu)

What you did

Ran the hot_asset_reloading example on my Window 10 desktop, and Ubuntu laptop.

CLI args:

cargo run --example hot_asset_reloading --features file_watcher

What went wrong

Updating the torus gltf file does not update the model while running. Specifically, I updated the rotation quaternion in the file. Only restarting the app shows me the change.

Additional information

Editing the base color of the monkey model (same example) in version 0.11 seems to work, though if I add a rotation quaternion, the monkey's rotation only updates upon restarting the app.

On a personal project, I'm listening for image events AssetEvent<Image>:

pub fn read_image_events(
    mut events: EventReader<AssetEvent<Image>>,
) {
    for event in events.read() {
        println!("Got event: {event:?}");
    }
}

This system runs in the Update schedule. When starting up my game, my console logs the following:

Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 3, generation: 0} }
Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 5, generation: 0} }
Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 4, generation: 0} }

After updating / saving an image file image a couple of times, the console log looks like this:

Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 3, generation: 0} }  // Old
Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 5, generation: 0} }  // Old
Got event: Added { id: AssetId<bevy_render::texture::image::Image>{ index: 4, generation: 0} }  // Old
2024-08-10T20:33:26.687117Z  INFO bevy_asset::server: Reloading maps\tilesets\spring_forest.png because it has changed // New
2024-08-10T20:33:26.769548Z  INFO bevy_asset::server: Reloading maps\tilesets\spring_forest.png because it has changed // New
2024-08-10T20:33:39.859572Z  INFO bevy_asset::server: Reloading maps\tilesets\spring_forest.png because it has changed // New
2024-08-10T20:33:39.951233Z  INFO bevy_asset::server: Reloading maps\tilesets\spring_forest.png because it has changed // New

The four new lines at the end are bevy's internal logging. Clearly, bevy is detecting the change, but for some reason, it does not fire AssetEvent::<Image>::Modified events.

The PBR models that I'm spawning do not seem to update either. They do update if I restart the app, or do something that causes them to reload manually.

Anti-Alias avatar Aug 10 '24 20:08 Anti-Alias

I too tried to run "hot_asset_reloading" (cargo run --example hot_asset_reloading --features file_watcher). I ran it on the main branch version of bevy, and 0.14.1. Neither of them worked when changing the scale and rotation, although both versions detect a change of the torus.gltf file, and prints to the console (... INFO bevy_asset::server: Reloading models\torus\torus.gltf because it has changed)

Maybe rotation and scale on gltf is only updated on app restart, and if so, I think there should be added some documentation, to inform people that some fields are not affected by hot reloading.

I'm on windows 10, I don't know if operating system has anything to do with this though.

Pnoenix avatar Aug 10 '24 21:08 Pnoenix

I might make a small example reproducing the lack of AssetEvent::<T>::Modified being fired for a variety of assets.

Anti-Alias avatar Aug 10 '24 22:08 Anti-Alias

Today I tried changing the config loading plugin I made (Github Repo), so that it doesn't require a Default implementation, and ran into the same issue as described above.

Before the asset was loaded with asset_server.load(...), however I changed it to be instantiated through asset_server.add(...), and then loading the asset itself with ron::de::from_str(...).

When doing it like this, both AssetEvent::LoadedWithDependencies and AssetEvent::Added gets called, however, AssetEvent::Modified no longer gets called.

This is on bevy version 0.14.1. This means that it is not only and issue with the GLTF asset/assetloader, and at least also a problem with certain custom asset loader implementations.

Pnoenix avatar Aug 11 '24 14:08 Pnoenix

@kaosat-dev this might be relevant for Blenvy

janhohenheim avatar Aug 11 '24 15:08 janhohenheim

I can confirm this issue being present in 0.14.1, although it worked correctly in the last Bevy rc as far as I can remember.

kaosat-dev avatar Aug 13 '24 11:08 kaosat-dev

AssetEvent::Modified event is not triggered by Embedded asset reloading too.

INFO bevy_asset::server: 1387: Reloading entities.json because it has changed INFO bevy_asset::server: 1387: Reloading entities.png because it has changed

But zero AssetEvents are generated and systems can not reload changed assets.

PPakalns avatar Nov 22 '24 11:11 PPakalns

Added code to manually send AssetEvent::Modified events. Systems that use assets reload data, but nothing changes. It looks like assets themself are not even replaced with new version.

PPakalns avatar Nov 26 '24 15:11 PPakalns

bisected to 5eb292dc10b99e13c6f606b7d9f0018f59052574

hukasu avatar Mar 16 '25 20:03 hukasu

this issue only happens to changes that would modify a component like Transform, changing something that affects sub assets of the gltf works fine (i.e. changing a material)

modified the hot_asset_reloading example to use the flight helmet and edited the gltf to use different textures

https://github.com/user-attachments/assets/e3dc2809-863f-40f5-9283-fa210d498150

hukasu avatar Mar 16 '25 21:03 hukasu