-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Enable async setup of an application #8607
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
base: main
Are you sure you want to change the base?
Conversation
Can you say a bit more about the motivation here? Who would this be useful for, and why can't they use the existing approach? |
I still think an async API is cleaner, and I prefer it over the limited task executor embedded at the start of the event loop. Doing it this way is not contagious, and leave the decision to the consumer what they want to add async or sync, both can be mixed however the user want in the same app. I also find that adding support for this doesn't require a lot of code, and the only somewhat complex part is how to handle the waker in both native and wasm (https://github.com/mockersf/bevy/blob/c50406cfb48bbb1a70300fad5935a35755b2481b/crates/bevy_app/src/app.rs#L747-L762) It's a cleaner way to enable this kind of scenario #8553 (comment) from @JMS55 And as I may have mention, I like async things |
When https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html is stable, it will be possible to have real async plugins, and that will clean up the code nicely, while still keeping the possibility of not needing to put everything in async. |
My biggest concern here is that there are now two ways to do the exact same thing and we'll likely see a mix of both in tutorials / plugins / etc. Creates questions like "which way is the right way" that have no clear answer. |
Does this PR become more useful as #8624 becomes reality? As asset loading becomes more complex and potentially longer in duration via asset processing/pipelines, doesn't support for async become more practical (especially as rust itself continues to push this) for additional user level concurrent, implementations while waiting for asset code paths to complete? If so, does async become preferred under the covers, providing a synchronous await for the current synchronous APIs?
Isn't this the same answer as always? Synchronous if you want synchronous and asynchronous if you want asynchronous? Whereby continued support for this makes bevy more async friendly as it grows? Rust itself is continuing to push forward its async support. Shouldn't bevy follow? Is singular idiomatic bevy APIs the ideal for bevy vs idiomatic rust? Are they different? |
so... anyone ready to make Bevy full async? 😄 |
I'm not opposed 😅 As long as there's a single way and the incantation isn't dramatically more complex, I'm fine with unblocking this work. I would really like to get plugin dependencies and so on working properly. |
Triage: has merge conflicts |
Objective
Solution
build
/ready
/finish
steps of the plugin init to a future, and await that future#[bevy_main]
macro can handle an asyncmain
functionCurrent state
Plugins are built when called
add_plugins
, then the application starts and the event loop wait for plugins to be ready then finish their setup before actually starting the applicationNew async ✨
Plugins are built, waiting for them to be ready, then finished, and then the application can start directly