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

Explore asset hot reloading for bevy run web #189

Open
TimJentzsch opened this issue Dec 3, 2024 · 0 comments
Open

Explore asset hot reloading for bevy run web #189

TimJentzsch opened this issue Dec 3, 2024 · 0 comments
Labels
A-Run Related to the bevy run command A-Web Building or running Bevy apps targeting the browser C-Feature Make something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help!

Comments

@TimJentzsch
Copy link
Collaborator

TimJentzsch commented Dec 3, 2024

Asset hot reloading is a very important feature of Bevy.
Due to Rust's relatively slow compile times, it can really improve the speed of the development cycle.

Unfortunately, it's not available when targeting the browser.
The main reason is that web apps don't have direct access to the file system and we cannot assume a specific web server implementation, so no standard API to communicate file changes between the server and web client.

With the Bevy CLI, we have full control over the development web server!
So it's likely possible that we can make hot reloading work.

Requirements

  • Simple: Hot-reloading should work without additional configuration, or (if impossible) with very simple adjustments (e.g. adding one additional plugin to their app). They shouldn't have to make fundamental changes to their app.
  • Optional: If the user would have to make changes to their app in order to get hot reloading, they don't have to! Everything else should still work without adjustments. If we can make hot reloading work by default, the user should probably have a way to opt out.

Potential solutions

The Bevy CLI would create file watchers for the asset directory and then somehow communicate the changes to the Bevy app.
I can see two ways of communication:

  1. Client-authoritive: The Bevy app regularly makes API calls to the server, asking which changes happened since the last call.
  2. Server-authoritive: Whenever a change happens, the server directly sends them over to the client (perhaps using web-sockets?).

Afterwards, the Bevy app has to process these events, likely forwarding them to the asset server / asset source. This source then performs the reload, same as for native hot-reloading.
Triggering the internal hot-reload likely requires changes to Bevy itself, so we can access the relevant functionality from "outside".

@TimJentzsch TimJentzsch added C-Feature Make something new possible A-Build Related to the bevy build command A-Web Building or running Bevy apps targeting the browser D-Complex Quite challenging from either a design or technical perspective. Ask for help! labels Dec 3, 2024
@TimJentzsch TimJentzsch added A-Run Related to the bevy run command and removed A-Build Related to the bevy build command labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Run Related to the bevy run command A-Web Building or running Bevy apps targeting the browser C-Feature Make something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help!
Projects
None yet
Development

No branches or pull requests

1 participant