Closed SmallNibbler closed 2 years ago
Calling AssetServer::watch_for_changes()
initialises the filesystem watcher synchronously. Calling AssetServer::load_folder()
eventually spawns a call to the internal AssetServer::load_async()
as a task on a TaskPool. That is, it is called asynchronously and after load_folder()
returns, the timing of those tasks executing can and will vary. At the end of load_async()
, the path to the asset is added to the patches to be watched, but only if the filesystem watcher has been initialised and exists.
Hopefully from this description of how the code works, it is clear that this code is racey. I discovered this while investigating inconsistency in how hot-reloading was working and fixing it here: https://github.com/bevyengine/bevy/pull/3643
You could also try enabling the watcher first, and then calling load_folder.
This helped, thanks.
You could also try enabling the watcher first, and then calling load_folder.
Bevy version
[package] name = "experimental" version = "0.1.0" edition = "2021"
[dependencies] anyhow = "1.0.52"
[dependencies.bevy] version = "0.6.0" default-features = false features = [ "filesystem_watcher", "bevy_dynamic_plugin", "render", "bevy_winit", "png", "x11", ]
Operating system & version
Operating System: Manjaro Linux KDE Plasma Version: 5.23.4 KDE Frameworks Version: 5.89.0 Qt Version: 5.15.2 Kernel Version: 5.15.12-1-MANJARO (64-bit) Graphics Platform: X11 Processors: 4 × Intel® Pentium® CPU 3825U @ 1.90GHz Memory: 7.7 Gb of RAM Graphics Processor: Mesa Intel® HD Graphics
What you did
code_loader.rs
main.rs
What does this code mean: There is an asset defenition in code_loader.rs. Asset with a plain text from .rs file. main.rs algorithm:
Handle<Code>
.Vec<Handle<Code>>
.What you expected to happen
In most situations one file of the three is tracked, rarely two of three, sometimes no one. In the next example i'm loading two files from folder, one is tracked or no one.
What actually happened