Bevy hot asset reloader decides to scan every file in project directory
Bevy version
0.14.1
Relevant system information
Linux, nixOS
What you did
- Use cargo-generate to make a bevy project with the Bevy quickstart template
- Add a flake.nix and a few other things to provide dependencies
- Run the program
What went wrong
Startup takes about ~10s on my moderately fast machine (that is, time from executable launch to window opening) Removing the 'file_watcher' and (probably not related) 'embedded_watcher' feature cuts this down significantly (to what I would expect - maybe 1s or so)
Additional information
I ran strace to see what could possibly take so long. A typical section of the very long output is
openat(AT_FDCWD, "<<PROJECT_FOLDER>>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 9
fstat(9, {st_mode=S_IFDIR|0555, st_size=3, ...}) = 0
statx(AT_FDCWD, "<<PROJECT_FOLDER>>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0555, stx_size=3, ...}) = 0
getdents64(9, 0x55f146642040 /* 3 entries */, 32768) = 80
statx(AT_FDCWD, "<<PROJECT_FOLDER>>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio/default.nix", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=791, ...}) = 0
getdents64(9, 0x55f146642040 /* 0 entries */, 32768) = 0
close(9)
TLDR: it's crawling every file in the project directory. In this case, it's managed to find a symlink provided by the nix flake, which sends it crawling the entire Nixpkgs source, which explains part of just why it takes so long, but regardless of nix, it still also crawls ./target, which has plenty of files put there by Cargo.
I can't figure out why it would crawl the whole project directory like this. Maybe I've misconfigured something? Anyway, it should only crawl ./assets at most, and if it does a full crawl of that folder, this behaviour would still be nice to document...
Good investigation! This should be at a stage where we can poke around the source and try to identify why this is happening.
Embedded assets are stored in the src/ directory, so maybe it is related to embedded_watcher specifically?