bevyengine / bevyengine/bevy

`file_watcher` does not reload assets on all file changes

Open
#10,576 2 comments 0 reactions 0 assignees View on GitHub
A-Assets C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

0.12

## \[Optional\] Relevant system information

This is on Arch Linux and may not reproduce on other OSes.

## What you did

Enable the `file_watcher` feature and use [Krita](https://krita.org/) to edit and overwrite a `.png` in the assets folder.

## What went wrong

The asset was not reloaded.

## Additional information

I've added logging to the file watcher and the logs look like this:

```
2023-11-15T21:46:55.234399Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Remove(File), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png~"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41791, tv_nsec: 238759780 } }
2023-11-15T21:46:56.660576Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Remove(File), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41792, tv_nsec: 629211904 } }
2023-11-15T21:46:56.660599Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Create(File), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41792, tv_nsec: 629295051 } }
2023-11-15T21:46:56.660605Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Modify(Data(Any)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41792, tv_nsec: 629496794 } }
2023-11-15T21:46:56.660617Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Access(Close(Write)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41792, tv_nsec: 629499589 } }
2023-11-15T21:46:56.677479Z INFO bevy_asset::server: Reloading soyR.png because it has changed
2023-11-15T21:47:16.251203Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Modify(Data(Any)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242008"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41812, tv_nsec: 221865734 } }
2023-11-15T21:47:16.251236Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Create(File), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png~"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41812, tv_nsec: 224080219 } }
2023-11-15T21:47:16.251245Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Access(Close(Write)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242008"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41812, tv_nsec: 224084517 } }
2023-11-15T21:47:18.277851Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Modify(Metadata(Any)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242009"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41814, tv_nsec: 255643983 } }
2023-11-15T21:47:18.277883Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Modify(Data(Any)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242009"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41814, tv_nsec: 312283508 } }
2023-11-15T21:47:18.352962Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Modify(Data(Any)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242009"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41814, tv_nsec: 361439227 } }
2023-11-15T21:47:18.352998Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Create(File), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/soyR.png"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41814, tv_nsec: 363762208 } }
2023-11-15T21:47:18.353004Z DEBUG bevy_asset::io::file::file_watcher: DebouncedEvent { event: Event { kind: Access(Close(Write)), paths: ["/home/sludge/code/Artifice/crates/artifice/../../assets/#42242009"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 41814, tv_nsec: 363766797 } }
```

You can see that the first reload happens correctly (this is in response to me reverting previous changes via git), but there is no second reload after the file has been replaced by Krita.

Contributor guide

Open the contributing guide

Research direction

Start at bevy_asset::io::file::file_watcher and trace how the file watcher events reach asset reloading in the asset server. Reproduce the Krita overwrite sequence with the file_watcher feature, then verify that replacing an existing .png produces a reload rather than only logging filesystem events.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.