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

bevy_asset_loader + trunk: Changes in assets folder trigger ~10 reloads #110

Closed
cxreiff opened this issue Mar 10, 2023 · 2 comments
Closed

Comments

@cxreiff
Copy link

cxreiff commented Mar 10, 2023

I am using bevy_asset_loader and dynamic asset loading (a .manifest file) on an example repository created from @NiklasEi's template here (https://github.com/NiklasEi/bevy_game_template). When the app is served to a browser using Trunk, and anything is created or modified in the assets directory, it causes Trunk's automatic reloading functionality to trigger over and over again.

Trunk uses v4 of the notify crate, which is build on top of the FSEvents API on Mac OS, so I used fsevents to print out the filesystem events when adding an empty file to the assets directory with touch assets/test:

notify_events: Notifying events #: 1.
/Users/jaxreiff/Documents/untitled/assets/test Created IsFile AttributeModified
notify_events: Notifying events #: 4.
/Users/jaxreiff/Documents/untitled/assets/textures/app_icon.png IsFile
/Users/jaxreiff/Documents/untitled/assets/textures/kitty.png IsFile
/Users/jaxreiff/Documents/untitled/assets/test Created IsFile AttributeModified
/Users/jaxreiff/Documents/untitled/assets/manifest.assets IsFile
notify_events: Notifying events #: 4.
/Users/jaxreiff/Documents/untitled/assets/textures/app_icon.png IsFile
/Users/jaxreiff/Documents/untitled/assets/textures/kitty.png IsFile
/Users/jaxreiff/Documents/untitled/assets/test Created IsFile AttributeModified
/Users/jaxreiff/Documents/untitled/assets/manifest.assets IsFile
notify_events: Notifying events #: 4.
/Users/jaxreiff/Documents/untitled/assets/textures/app_icon.png IsFile
...

...repeated ten or so times. From this, it seems that bevy_asset_loader is doing something to the assets folder during build that generates a filesystem event, which then triggers another build, and so on. Eventually the loop stops, after a varying amount of loops, my only explanation for which is that potentially the debouncing built into notify is breaking the loop.

Initially, I thought this may be related to notify-rs/notify#465 or watchexec/cargo-watch#242, but printing the filesystem events showed that the "AttributeModified" event is being triggered on the new file over and over again, which notify is probably correct to pick up.

My apologies if this issue belongs in another repository- unfortunately this appears to be a strange (potentially platform-specific) interaction between a number of dependencies so it is difficult to nail down.

Example repository: https://github.com/cxreiff/untitled

OS: macOS 13.2.1
CPU: (12) arm64 Apple M2 Max

@NiklasEi
Copy link
Owner

I cannot reproduce this on linux using your repository. Do you still see this issue without using dynamic assets?

@cxreiff
Copy link
Author

cxreiff commented Jun 26, 2023

This issue only occurs for me while using dynamic assets, however since opening this I have noticed related issues being discussed on the Trunk repository itself, which very well might resolve my issue:
trunk-rs/trunk#461
trunk-rs/trunk#516

So I think I can resolve this in favor of that PR for now. I'll re-open if it turns out to be unrelated! Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants