subsecond
issuesthis portion was initially written by L, to provide a reference point for discussion
The API for hot reloading should be as close as possible to "vanilla" bevy - some changes will be needed, but we should aim for them to be minimal and for the abstractions to disappear in production code.
Rust - as a compiled, statically typed language - is not set up well for reloading abitrary code. In addition, we don't necessarily want to incur the cost of enabling reload in areas that will rarely change - such as in crate dependencies. This suggests we should have a granular approach of reloading only things that changed.
On the flip side, if we only reload the minimal changes we risk having elements that rely on multiple versions of a struct running side by side, for example. So it's important that we expand the scope of reload to include everything that we want to be capable of change.
The bevy plugin ends up being a good middle ground here - it covers less area than the entire app, preventing the need to reload everything, and more area than a single system.
ridiculous_bevy_hot_reloading
& bevy_simple_subsecond_system
rely on marking a function as #[hot]
to get it to reload, while dexterous_developer
relies on creating a reloadable_scope!(|app| { /** Setup code **/})
that gets added from within a plugin.
bevy_simple_subsecond_system
only uses a proc macro to save a tiny bit of boilerplate: https://github.com/DioxusLabs/dioxus/issues/4143However, we can set things up more directly in the plugin scope using one of the following approaches:
#[hot]
struct MyPlugin;
impl ReloadablePlugin for MyPlugin {
fn (app: &mut ReloadableApp) { // ReloadableApp would have a subset of the capabilities of &mut App, to enforce only elements that support reloading in the plugin
// implement your plugin here
}
}
// when setting up the plugin
app.add_plugins(MyPlugin)
or
#[hot]
struct MyPlugin;
impl Plugin for MyPlugin {
fn (app: &mut App) { // Here we can't enforce limitations on what is loaded
}
}
// when setting up the plugin
app.add_reloadable_plugins(MyPlugin)
For the MVP, either option could work (and in fact, so would just #[hot] on a sysstem), since it doesn't require handling changes to data structures. However, I believe setting up with the first option will make things easier for the future.
comment by Jan Hohenheim
Alternatively, the boilerplate that the #[hot]
annotation generates can also just be moved to the add_systems
or IntoSystem
implementation behind a feature
gate / config, similar to how hot reloading works today. This way, all systems in the app will automagically benefit from hotpatching when a user turns that feature on. No annotations necessary, no new API is introduced.
comment by L note that this approach won't support adding/removing systems on the go. for that we would need to set up either the whole app or the plug-ins as reloadable. the main concern around reloading the whole app is loading assets into memory and re-running setup code (which could end up corrupting the current state you are trying to hot patch)
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing