-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Hot patching systems with subsecond #19309
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
Open
mockersf
wants to merge
27
commits into
bevyengine:main
Choose a base branch
from
mockersf:hot-patching
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+393
−2
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
06d9d6c
easy hot-patching
mockersf ca7d5cf
checking jump table only when needed
mockersf 6eeae7f
clippy
mockersf 5ac3e41
example readme
mockersf dc635d8
also feature doc
mockersf d92ae90
safety comment
mockersf 3be68fa
nicer example systems
mockersf d4290fb
fix review
mockersf 21ff0de
move hotpatch plugin to bevy_dev_tools
mockersf 9c73e08
log when a system is hot-reloaded
mockersf 6f6490b
example on how to patch something out of the ecs
mockersf 23dc91d
change log level
mockersf 0e7ab18
formatting
mockersf 5ced020
comments
mockersf 27acbd7
example improvements
mockersf 5a540a1
Apply suggestions from code review
mockersf a60862a
Update crates/bevy_ecs/src/lib.rs
mockersf 04157b8
use main from Dioxus
mockersf 71dbff9
cfg gate refresh_hotpatch
mockersf 1955f30
use builtin helpers from subsecond
mockersf 4610edb
remove unsafe expect
mockersf 834b5c5
gate wasm as connect_subsecond is not available there
mockersf aed45ef
clippy
mockersf 03adba3
actual safety comment
mockersf 79340eb
alloc
mockersf 4231925
exclusive systems
mockersf 468d1f0
basic release note
mockersf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Utilities for hotpatching code. | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extern crate alloc; | ||
|
||
use alloc::sync::Arc; | ||
|
||
use bevy_ecs::{event::EventWriter, HotPatched}; | ||
#[cfg(not(target_family = "wasm"))] | ||
use dioxus_devtools::connect_subsecond; | ||
use dioxus_devtools::subsecond; | ||
|
||
pub use dioxus_devtools::subsecond::{call, HotFunction}; | ||
|
||
use crate::{Last, Plugin}; | ||
|
||
/// Plugin connecting to Dioxus CLI to enable hot patching. | ||
#[derive(Default)] | ||
pub struct HotPatchPlugin; | ||
|
||
impl Plugin for HotPatchPlugin { | ||
fn build(&self, app: &mut crate::App) { | ||
let (sender, receiver) = crossbeam_channel::bounded::<HotPatched>(1); | ||
|
||
// Connects to the dioxus CLI that will handle rebuilds | ||
// This will open a connection to the dioxus CLI to receive updated jump tables | ||
// Sends a `HotPatched` message through the channel when the jump table is updated | ||
#[cfg(not(target_family = "wasm"))] | ||
connect_subsecond(); | ||
subsecond::register_handler(Arc::new(move || { | ||
sender.send(HotPatched).unwrap(); | ||
})); | ||
|
||
// Adds a system that will read the channel for new `HotPatched`, and forward them as event to the ECS | ||
app.add_event::<HotPatched>().add_systems( | ||
Last, | ||
move |mut events: EventWriter<HotPatched>| { | ||
if receiver.try_recv().is_ok() { | ||
events.write_default(); | ||
} | ||
}, | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,8 @@ critical-section = [ | |
"bevy_reflect?/critical-section", | ||
] | ||
|
||
hotpatching = ["dep:subsecond"] | ||
|
||
[dependencies] | ||
bevy_ptr = { path = "../bevy_ptr", version = "0.16.0-dev" } | ||
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [ | ||
|
@@ -124,6 +126,7 @@ variadics_please = { version = "1.1", default-features = false } | |
tracing = { version = "0.1", default-features = false, optional = true } | ||
log = { version = "0.4", default-features = false } | ||
bumpalo = "3" | ||
subsecond = { git = "https://github.com/DioxusLabs/dioxus", optional = true } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure git dependencies will make this unpublishable on crates.io There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the PR description I think this is meant to be temporary |
||
|
||
concurrent-queue = { version = "2.5.0", default-features = false } | ||
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.