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

Assets: fix first hot reloading #9804

Merged
merged 3 commits into from
Oct 26, 2023
Merged

Conversation

mockersf
Copy link
Member

Objective

  • Hot reloading doesn't work the first time it is used

Solution

  • Currently, Bevy processor:
    1. Create the imported_assets folder
    2. Setup a watcher on it
    3. Clear empty folders, so the imported_assets folder is deleted
    4. Recreate the imported_assets folder and add all the imported assets
  • On a first run without an existing imported_assets with some content, hot reloading won't work as step 3 breaks the file watcher
  • This PR stops the empty root folder from being deleted
  • Also don't setup the processor internal asset server for file watching, freeing up a thread

@mockersf mockersf added the A-Assets Load files from disk to use for things like images, models, and sounds label Sep 14, 2023
@hymm hymm added this to the 0.12 milestone Sep 20, 2023
@alice-i-cecile alice-i-cecile added the C-Bug An unexpected or incorrect behavior label Oct 18, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After digging around, I agree with both of these changes.

Copy link
Member

@NiklasEi NiklasEi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can reproduce the issue and the fix in the asset_processor example.
One thing I noticed: with the fix, everything will be reloaded once after startup. I guess the processing is triggering some file event? But I would not block on that since it only happens the first time and is less of an issue compared to no hot reloading at all.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 25, 2023
Copy link
Member

@cart cart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed merge conflicts. This removes your "no watching for asset processor server" change, as the equivalent already exists thanks to the Multiple Asset Sources pr.

@cart cart enabled auto-merge October 26, 2023 21:14
@cart cart added this pull request to the merge queue Oct 26, 2023
Merged via the queue into bevyengine:main with commit e5b3cc4 Oct 26, 2023
21 checks passed
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

- Hot reloading doesn't work the first time it is used

## Solution

- Currently, Bevy processor:
  1. Create the `imported_assets` folder
  2. Setup a watcher on it
  3. Clear empty folders, so the `imported_assets` folder is deleted
4. Recreate the `imported_assets` folder and add all the imported assets
- On a first run without an existing `imported_assets` with some
content, hot reloading won't work as step 3 breaks the file watcher
- This PR stops the empty root folder from being deleted
- Also don't setup the processor internal asset server for file
watching, freeing up a thread

---------

Co-authored-by: Carter Anderson <[email protected]>
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Hot reloading doesn't work the first time it is used

## Solution

- Currently, Bevy processor:
  1. Create the `imported_assets` folder
  2. Setup a watcher on it
  3. Clear empty folders, so the `imported_assets` folder is deleted
4. Recreate the `imported_assets` folder and add all the imported assets
- On a first run without an existing `imported_assets` with some
content, hot reloading won't work as step 3 breaks the file watcher
- This PR stops the empty root folder from being deleted
- Also don't setup the processor internal asset server for file
watching, freeing up a thread

---------

Co-authored-by: Carter Anderson <[email protected]>
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 S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants