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

Hot reloading for external levels #1

Closed
Trouv opened this issue Nov 13, 2021 · 2 comments
Closed

Hot reloading for external levels #1

Trouv opened this issue Nov 13, 2021 · 2 comments

Comments

@Trouv
Copy link
Owner

Trouv commented Nov 13, 2021

Hot reloading for external levels is pretty close, but when you save a level in the LDtk editor, bevy gives this warning without any AssetEvent being fired:

WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: /home/trouv/projects/bevy_ecs_ldtk/assets/levels/0000-Level_0.ldtkl
WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: /home/trouv/projects/bevy_ecs_ldtk/assets/levels/0001-Level_1.ldtkl

This is the correct path for the file and it does still exist after save.
The only thing I can think of is that maybe the way LDtk saves these level files is that it deletes the file first then writes to it a millisecond later, and bevy hot-reloading doesn't like that.
However, I looked into the LDtk source code and it looks like it's just using Node.js's writeFileSync() function, but maybe I'm missing something.

I saw in notify::poll::PollWatcher (which bevy seems to use for hot-reloading on linux) that you can set a delay for polling the filesystem, which may resolve the issue most of the time if I set it to like 50 ms or something.
I don't think that particular value is controllable from the bevy api though.
Maybe bevy should still be capable of writing AssetEvents in this scenario in the future?
This is probably upstream issue.

@Trouv
Copy link
Owner Author

Trouv commented Apr 10, 2022

The workaround for this right now is to just hit save twice.

@Trouv
Copy link
Owner Author

Trouv commented Oct 19, 2023

This seems to be fixed since bevy's changewatcher now accepts a duration.

@Trouv Trouv closed this as completed Oct 19, 2023
Trouv added a commit that referenced this issue Oct 20, 2023
Related to #1 

Since bevy's file changewatcher now accepts a `Duration`, running into
the bug caused by level files being temporarily unavailable is either
extremely unlikely or impossible with a reasonable duration. So, I think
it's safe to remove this caveat from the readme saying that users need
to double-save for hot-reloading to work for external levels.
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

1 participant