-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
SubApp::extract cannot be called due to borrow checker #14003
Comments
Can you give a bit more context on why you're using this pattern? I'd like to remove sub-apps completely, and want a better sense of the advanced use cases. |
I have a UI system (not bevy's!) and want to display bevy views as UI views, and there might be multiples of them. There's a place in the app where I have to tell bevy to render that specific view to wgpu's queue right now (synchronously), which should be achievable by running It would be nice to have separate worlds for these views. I thought about using completely separate bevy Apps for this, but then I couldn't share entities when necessary. Also, I'd have to set up all systems for every App again and again. |
Okay, so pretty standard multi-world / entity partitioning stuff. Thanks! As for this issue, please feel free to make a simple PR to expose an API to do so. |
I have made a simple PR to expose an API called |
Yes, thank you! |
…pp. (#14009) # Objective - Fixes #14003 ## Solution - Expose an API to perform updates for a specific sub-app, so we can avoid mutable borrow the app twice. ## Testing - I have tested the API by modifying the code in the `many_lights` example with the following changes: ```rust impl Plugin for LogVisibleLights { fn build(&self, app: &mut App) { let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; }; render_app.add_systems(Render, print_visible_light_count.in_set(RenderSet::Prepare)); } fn finish(&self, app: &mut App) { app.update_sub_app_by_label(RenderApp); } } ``` --- ## Changelog - add the `update_sub_app_by_label` API to `App` and `SubApps`. --------- Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
…pp. (#14009) # Objective - Fixes #14003 ## Solution - Expose an API to perform updates for a specific sub-app, so we can avoid mutable borrow the app twice. ## Testing - I have tested the API by modifying the code in the `many_lights` example with the following changes: ```rust impl Plugin for LogVisibleLights { fn build(&self, app: &mut App) { let Some(render_app) = app.get_sub_app_mut(RenderApp) else { return; }; render_app.add_systems(Render, print_visible_light_count.in_set(RenderSet::Prepare)); } fn finish(&self, app: &mut App) { app.update_sub_app_by_label(RenderApp); } } ``` --- ## Changelog - add the `update_sub_app_by_label` API to `App` and `SubApps`. --------- Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
Bevy version
0.14.0-rc.3
What you did
I'm trying to call extract/update on a single SubApp instead of all at once.
What went wrong
Here is the code:
I'd like to run extract.
Compiler error in the
if let
line: cannot borrow app mutable more than once, first borrow happens in the line defining theworld
variable.I don't see a way to use the
extract
function at all, since the world I have to pass is always part of the enclosing context, and thus the borrow checker will never allow that.Additional information
SubApps::update
works, because it can do a partial borrow ofself
, but since I don't have access toSubApps
, I can't do the same from outside the bevy_app crate.This is an inherent limitation of Rust's borrow checker, because it can't do partial borrows on references returned from function calls.
The text was updated successfully, but these errors were encountered: