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

Injecting LogPlugin twice causes a panic #6426

Closed
bayou-brogrammer opened this issue Oct 30, 2022 · 3 comments
Closed

Injecting LogPlugin twice causes a panic #6426

bayou-brogrammer opened this issue Oct 30, 2022 · 3 comments
Labels
A-App Bevy apps and plugins C-Bug An unexpected or incorrect behavior

Comments

@bayou-brogrammer
Copy link

Bevy version

Main branch (0.9-dev)

[Optional] Relevant system information

Specs: 14-in M1 Macbook Pro running 12.6 Monterey, with 32 GB Ram

What you did

Injecting DefaultPluigins while also modifying the LogPlugin, works as expected.

DefaultPlugins
            .set(WindowPlugin {
                window: WindowDescriptor {
                    width: WINDOW_WIDTH,
                    height: WINDOW_HEIGHT,
                    title: String::from(LAUNCHER_TITLE),
                    // present_mode: bevy::window::PresentMode::AutoVsync,
                    ..default()
                },
                ..default()
            })
            .set(ImagePlugin::default_nearest())
            .set(bevy::log::LogPlugin { ..default() });

Injecting a second LogPlugin causes a panic for bevy::log/src/lib.rs:118:27

app.add_plugin(bevy::log::LogPlugin { ..default() });

Only when I disable the log plugin from the initial DefaultPlugins does it actually allow me to inject a second context.

defaults.build().disable::<bevy::log::LogPlugin>()
...

// Yay this works :)
app.add_plugin(bevy::log::LogPlugin { ..default() });

Additional information

Here is the full stack trace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SetLoggerError(())', /Users/elkxj/.cargo/git/checkouts/bevy-f7ffde730c324c74/7540328/crates/bevy_log/src/lib.rs:118:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@bayou-brogrammer bayou-brogrammer added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 30, 2022
@mockersf
Copy link
Member

related to #1969
panic would change with #6411

@alice-i-cecile alice-i-cecile added A-App Bevy apps and plugins and removed S-Needs-Triage This issue needs to be labelled labels Oct 30, 2022
@alice-i-cecile
Copy link
Member

Fixed by #6411.

@bayou-brogrammer
Copy link
Author

You guys are the best! Thanks!

bors bot pushed a commit that referenced this issue Nov 28, 2022
# Objective

When a global tracing subscriber has already been set, `LogPlugin` panics with an error message explaining this. However, if a global logger has already been set, it simply panics on an unwrap.

#6426 mentiones the panic and has been fixed by unique plugins, but the panic can still occur if a logger has been set through different means or multiple apps are created, as in  #4934. The solution to that specific case isn't clear; this PR only fixes the missing error message.

## Solution

- ~add error message to panic~
- turn into warning
taiyoungjang pushed a commit to taiyoungjang/bevy that referenced this issue Dec 15, 2022
# Objective

When a global tracing subscriber has already been set, `LogPlugin` panics with an error message explaining this. However, if a global logger has already been set, it simply panics on an unwrap.

bevyengine#6426 mentiones the panic and has been fixed by unique plugins, but the panic can still occur if a logger has been set through different means or multiple apps are created, as in  bevyengine#4934. The solution to that specific case isn't clear; this PR only fixes the missing error message.

## Solution

- ~add error message to panic~
- turn into warning
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

When a global tracing subscriber has already been set, `LogPlugin` panics with an error message explaining this. However, if a global logger has already been set, it simply panics on an unwrap.

bevyengine#6426 mentiones the panic and has been fixed by unique plugins, but the panic can still occur if a logger has been set through different means or multiple apps are created, as in  bevyengine#4934. The solution to that specific case isn't clear; this PR only fixes the missing error message.

## Solution

- ~add error message to panic~
- turn into warning
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

When a global tracing subscriber has already been set, `LogPlugin` panics with an error message explaining this. However, if a global logger has already been set, it simply panics on an unwrap.

bevyengine#6426 mentiones the panic and has been fixed by unique plugins, but the panic can still occur if a logger has been set through different means or multiple apps are created, as in  bevyengine#4934. The solution to that specific case isn't clear; this PR only fixes the missing error message.

## Solution

- ~add error message to panic~
- turn into warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants