For convenience, I have copy/pasted the content of the original post here:
I have a plugin that is using EguiPlugin in my app, and I also have some dependencies that use it (bevy_editor_pls).
It's wrapped in a guard (with some added debug logging not shown in the code but you can see the output in the logs below) so that it should not be added more than once
if !app.is_plugin_added::<EguiPlugin>() {
app.add_plugins(EguiPlugin);
}
However this guard doesn't seem to be working. When I pull in my dependency bevy_editor_pls that I know also includes the plugin with the same kind of guard
I have looked at the bevy code for how the plugin is loaded and detected and it retrieves a boxed ref for the plugin and checks a downcast_ref of the trait obj inside the box and in this case that is somehow returning false (I logged it above).
I do see that the add_plugin doesn't add the plugin right away. It adds a placeholder then has the plugin build itself, and then adds it back if that succeeds. I have no idea if that is relevant. But it seems clear that the plugin_name_added HashSet has the plugin name in it, but the plugin_registry doesn't think it has the plugin yet.
As a secondary test, I tried the same thing with a different plugin and that seemed to work, so this may be some issue with bevy_egui / EguiPlugin and how it builds, and not with Bevy itself. But looking at the EguiPlugin build function so far nothing jumps out to me as to why this would be an issue.
That's as far as I've gotten, I hope someone has an idea what is going on?
I originally posted this in the Bevy Q&A list but after looking a bit more, I'm wondering if it's an issue with this library?
https://github.com/bevyengine/bevy/discussions/11482
For convenience, I have copy/pasted the content of the original post here:
I have a plugin that is using EguiPlugin in my app, and I also have some dependencies that use it (bevy_editor_pls).
It's wrapped in a guard (with some added debug logging not shown in the code but you can see the output in the logs below) so that it should not be added more than once
However this guard doesn't seem to be working. When I pull in my dependency
bevy_editor_pls
that I know also includes the plugin with the same kind of guardhttps://github.com/jakobhellermann/bevy_editor_pls/blob/main/crates/bevy_editor_pls_core/src/lib.rs#L65
and I run my app, I get a panic with a message indicating it has tried to duplicate the loading of
EguiPlugin
I have looked at the bevy code for how the plugin is loaded and detected and it retrieves a boxed ref for the plugin and checks a downcast_ref of the trait obj inside the box and in this case that is somehow returning false (I logged it above).
I do see that the add_plugin doesn't add the plugin right away. It adds a placeholder then has the plugin build itself, and then adds it back if that succeeds. I have no idea if that is relevant. But it seems clear that the plugin_name_added HashSet has the plugin name in it, but the plugin_registry doesn't think it has the plugin yet.
As a secondary test, I tried the same thing with a different plugin and that seemed to work, so this may be some issue with bevy_egui / EguiPlugin and how it builds, and not with Bevy itself. But looking at the EguiPlugin build function so far nothing jumps out to me as to why this would be an issue.
That's as far as I've gotten, I hope someone has an idea what is going on?