Skip to content
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

init_gizmo_group silently ignores missing RenderApp if in wrong order #13294

Open
RubenArtmann opened this issue May 9, 2024 · 1 comment
Open
Labels
A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes

Comments

@RubenArtmann
Copy link

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

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

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::<T>);

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

        #[cfg(feature = "bevy_sprite")]
        if app.is_plugin_added::<bevy_sprite::SpritePlugin>() {
            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

@RubenArtmann RubenArtmann added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 9, 2024
@alice-i-cecile alice-i-cecile added A-Gizmos Visual editor and debug gizmos S-Blocked This cannot move forward until something else changes and removed S-Needs-Triage This issue needs to be labelled labels May 13, 2024
@alice-i-cecile
Copy link
Member

Another casualty of #1255.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes
Projects
None yet
Development

No branches or pull requests

2 participants