-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Deprecate current bevy_dynamic_plugin
implementation
#11969
Comments
FYI @cart. I know you pushed back on this in #3893 in the past.
I think the landscape has meaningfully changed here on the editor side, between the existence of
Overall while I share these concerns I'd be fine to leave this around until we have a good sense of the architecture of the editor, and how editor extensions in particular will work. |
I should note that I am biased here - as the maintainer of I also think that the solutions for dynamic loading in a development context should be different than the ones used for things like DLC and mods - the constraints around them are very different:
I do think it might be worth looking at adding stabby to Bevy as an optional feature for ABI stability, and then we can use that as a basis for both the bevy plugin in dexterous developer (or for integrating that plugin into bevy) and for a separate approach for handling release-capable dynamic libraries for mods and DLC. |
I just opened #12029. While it does not deprecate |
# Objective - The current implementation for dynamic plugins is unsound. Please see #11969 for background and justification. - Closes #11969 and closes #13073. ## Solution - Deprecate all dynamic plugin items for Bevy 0.14, with plans to remove them for Bevy 0.15. ## Discussion One thing I want to make clear is that I'm not opposed to dynamic plugins _in general_. I think they can be handy, especially for DLC and modding, but I think the current system is the wrong approach. It's too much of a footgun for the meager benefit is provides. --- ## Changelog - Deprecated the current dynamic plugin system. - Dynamic plugins will be removed in Bevy 0.15. For now you can continue using them by marking your code with `#[allow(deprecated)]`. ## Migration Guide If possible, remove all usage of dynamic plugins. ```rust // Old #[derive(DynamicPlugin)] pub struct MyPlugin; App::new() .load_plugin("path/to/plugin") .run(); // New pub struct MyPlugin; App::new() .add_plugins(MyPlugin) .run(); ``` If you are unable to do that, you may temporarily silence the deprecation warnings. ```rust #[allow(deprecated)] ``` Please note that the current dynamic plugin system will be removed by the next major Bevy release, so you will have to migrate eventually. You may be interested in these safer alternatives: - [Bevy Assets - Scripting]: Scripting and modding libraries for Bevy - [Bevy Assets - Development tools]: Hot reloading and other development functionality - [`stabby`]: Stable Rust ABI [Bevy Assets - Scripting]: https://bevyengine.org/assets/#scripting [Bevy Assets - Development tools]: https://bevyengine.org/assets/#development-tools [`stabby`]: https://github.com/ZettaScaleLabs/stabby
# Objective - The current implementation for dynamic plugins is unsound. Please see bevyengine#11969 for background and justification. - Closes bevyengine#11969 and closes bevyengine#13073. ## Solution - Deprecate all dynamic plugin items for Bevy 0.14, with plans to remove them for Bevy 0.15. ## Discussion One thing I want to make clear is that I'm not opposed to dynamic plugins _in general_. I think they can be handy, especially for DLC and modding, but I think the current system is the wrong approach. It's too much of a footgun for the meager benefit is provides. --- ## Changelog - Deprecated the current dynamic plugin system. - Dynamic plugins will be removed in Bevy 0.15. For now you can continue using them by marking your code with `#[allow(deprecated)]`. ## Migration Guide If possible, remove all usage of dynamic plugins. ```rust // Old #[derive(DynamicPlugin)] pub struct MyPlugin; App::new() .load_plugin("path/to/plugin") .run(); // New pub struct MyPlugin; App::new() .add_plugins(MyPlugin) .run(); ``` If you are unable to do that, you may temporarily silence the deprecation warnings. ```rust #[allow(deprecated)] ``` Please note that the current dynamic plugin system will be removed by the next major Bevy release, so you will have to migrate eventually. You may be interested in these safer alternatives: - [Bevy Assets - Scripting]: Scripting and modding libraries for Bevy - [Bevy Assets - Development tools]: Hot reloading and other development functionality - [`stabby`]: Stable Rust ABI [Bevy Assets - Scripting]: https://bevyengine.org/assets/#scripting [Bevy Assets - Development tools]: https://bevyengine.org/assets/#development-tools [`stabby`]: https://github.com/ZettaScaleLabs/stabby
What problem does this solve or what need does it fill?
bevy_dynamic_plugin
is likely unsound, or at the very least so dangerous that it should not be an officially sanctioned crate. It currently works by derivingbevy_app::DynamicPlugin
onto a unit struct that implementsPlugin
. The code can then be built as acdylib
and loaded withbevy_dynamic_plugin::dynamically_load_plugin
.There are a few potential footguns / problems with this approach:
ctor
code unconditionally, without calling any functions.#[derive(DynamicPlugin)]
creates_bevy_create_plugin
, which returns&'static dyn Plugin
.dyn
references are fat pointers, where the metadata is a VTable. VTable layouts are not guaranteed.App
.TypeId
usage.TypePath
somewhat fixes this, but it's not used everywhere.What solution would you like?
Mark
dynamically_load_plugin
andDynamicPluginExt::load_plugin
as deprecated for Bevy 0.14. In Bevy 0.15, they will be removed andbevy_dynamic_plugin
will be turned into an empty crate likely moved tobevy-crate-reservations
.I think the current implementation is just too unsafe to continue in the main Bevy library. As mentioned by Alice, it may be worth recommending
dextrous_developer
in the module or deprecation notes.What alternative(s) have you considered?
Try to fix the above issues by exclusively using
TypePath
instead ofTypeId
and manually recreating the VTable struct. ctor is unavoidable, we just have to hope it won't be encountered in practice.Additional context
Some discussion on Discord on
bevy_dynamic_plugin
, while I was working on #11622.I think there is promise is dynamically loading plugins, so I would not be opposed to
bevy_dynamic_plugin
being re-introduced in the future, but I don't think the current implementation should be kept.The text was updated successfully, but these errors were encountered: