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

Filesystem watcher doesn't detect changes in removed/replaced files #3359

Open
Trouv opened this issue Dec 17, 2021 · 3 comments
Open

Filesystem watcher doesn't detect changes in removed/replaced files #3359

Trouv opened this issue Dec 17, 2021 · 3 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior

Comments

@Trouv
Copy link
Contributor

Trouv commented Dec 17, 2021

Bevy version

main, 7356f15

Operating system & version

Arch Linux

What you did

  1. In prep for file replacement: cp assets/models/cube/cube.bin assets/models/monkey/
  2. Run the hot_asset_reloading example
  3. While it's running, remove/replace the monkey model with:
#!/bin/bash
mv assets/models/monkey/Monkey.gltf assets/models/monkey/Monkey.gltf.bak
sleep 1
cp assets/models/cube/cube.gltf assets/models/monkey/Monkey.gltf

What you expected to happen

  1. Receive a warning about the missing file before it's been replaced
  2. After the file has been replaced, its changes are still detected and it is hot reloaded, so the cube is displayed instead of the monkey.

What actually happened

  1. Receive a warning, as expected:
WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: /home/trouv/projects/bevy/assets/models/monkey/Monkey.gltf
  1. After the file has been replaced, the monkey remains on display.

Additional information

I believe this is the main blocker for hot reloading "external levels" for LDtk files in my ldtk plugin. See this issue: Trouv/bevy_ecs_ldtk#1. I think somehow exposing the notify::poll::PollWatcher's delay to the bevy api somehow (maybe as a field in AssetServerSettings) could help resolve this issue. However, ideally I think bevy should fire AssetEvent::Modified in this scenario.

Sorry if this issue is upstream.

@Trouv Trouv added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 17, 2021
@alice-i-cecile alice-i-cecile added 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 Dec 17, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Dec 17, 2021

I think ldtk using writeFileSync is wrong either way. It allows other programs to observe a partially written state. The proper way to atomically change a file on unix is to first write it to a different file and then rename this file over the original file. This ensures that any program that had the original file open before writing will keep seeing the original file and any program opening the file after writing will see the new file. At no point would the file be missing.

@Trouv
Copy link
Contributor Author

Trouv commented Dec 23, 2021

I see, that makes sense. Still, I think it would be nice for bevy to detect changes in files after it can't read them for whatever reason. Whether it's missing or partially written or whatever

@StarArawn
Copy link
Contributor

I was able to reproduce this on Windows. I'm not receiving any AssetEvent::Modified events even when an asset has changed in the file system.

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

4 participants