bevyengine / bevyengine/bevy

`init_gizmo_group` silently ignores missing `RenderApp` if in wrong order

Open
#13,294 1 comment 0 reactions 0 assignees View on GitHub
A-Gizmos C-Bug S-Blocked
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version
0.13.2

## What you did

I had a plugin that loaded before `DefaultPlugins`.
Everything worked. Even the Gizmos (the default group is loaded by something else later).
I tried moving to my own `GizmoConfigGroup`.
I did everything like the 3d gizmo demo, but they would not render.
After an embarrassing amount of time i figured out, that i had to move the plugin initialization down one line.

## What went wrong

it seems you have moved the initialization of the gizmo renderer into GizmoPlugin::build now, which is better, because the plugin is probably loaded using DefaultPlugins and therefore in the correct order, but someone like me could still mess it up.
`bevy_gizmos/src/lib.rs` `GizmoPlugin::build`
```rust
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
```


for `release-0.13.2`

`bevy_gizmos/src/lib.rs` `App::init_gizmo_group`
```rust
let Ok(render_app) = self.get_sub_app_mut(RenderApp) else {
// this should probably panic!
return self;
};

// this is the expected (and needed if you do not have your own renderer) behaviour
render_app.add_systems(ExtractSchedule, extract_gizmo_data::);
```

## What should happen

The app should panic! (or at least warn!) if it can not find the renderer.

## Proposed Solution

you seem to have refactored it in the `main` branch, but you still dont do it like you do for the other plugins right under it
```rust

#[cfg(feature = "bevy_sprite")]
if app.is_plugin_added::() {
app.add_plugins(pipeline_2d::LineGizmo2dPlugin);
} else {
bevy_utils::tracing::warn!("bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?");
}
````


for `release-0.13.2`

The easiest solution would be to just panic if bevy was build with the renderer and it was not found,
but that would mean you could not use this function if you use a different Renderer and you build bevy with its own.

The better solution would probably be to just split the function into `init_gizmo_group_without_renderer` and `init_gizmo_group_and_renderer` (so old users get a compilation error and need to decide which version they need, or just use the old version and let people with a custom renderer deal with it, since it would panic for them).

this also affects `insert_gizmo_group`

Contributor guide

Open the contributing guide

Research direction

Start in bevy_gizmos/src/lib.rs at GizmoPlugin::build, App::init_gizmo_group, and insert_gizmo_group; trace how RenderApp is obtained and how plugin ordering is handled by the neighboring SpritePlugin checks. Done means missing-renderer setup is no longer silently ignored, while the behavior for custom renderers is explicitly resolved for both initialization paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.