-
-
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
Remove bevy_dynamic_plugin #3893
Conversation
I didn't find any current users of this functionality on github. |
47f34c2
to
672ad27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've long since wanted to tear this out.
it's also mentioned in Line 22 in 9a7852d
|
It is hard to use the current dynamic plugin system. It doesn't allow hot code swapping as several OSes don't allow unloading dylibs. It requires bevy itself to be used as dylib and it requires all other crates shared between the main game and the plugin to be dylibs. In the future we may get better plugin support. Whether based on wasm, or something else. Until then, remove the current dynamic plugin to avoid making any promises about the current ability to use dynamic plugins. If anyone wants to keep using the current dynamic plugin support despite all it's issues, they can copy the less than 100 lines of code this PR deletes.
672ad27
to
4dd6084
Compare
Fixed |
Yeah I'm open to removing this for now as we don't currently have significant motivating use cases. |
(of course unloading plugins should require an editor restart for safety) |
And if we agree that this provides value for a specific set of scenarios that we plan to encounter in the near future, is there a good reason to remove it in the interim? This isn't exactly a maintenance burden. Why not enable this use case for people that might encounter the need? |
The code is unsafe and unhelpful for users (but in an attractive way). It also limits our design thinking, where there's an instinct to build on top of an abstraction we already have, rather than thinking things through from the start.
Since I joined the project back in 0.2, I have never encountered a user who was using this.
|
I would argue that this is helpful, for the exact scenario mentioned above (loading features compiled separately from each other at the start up of a pre-compiled app). That isn't particularly niche. In addition to making editor experiences better for minimal additional effort, this would also enable things like "loading a dlc downloaded from the internet / distributed separately from the main game". I consider that to be very attractive and very helpful.
This is the result of a reasonable amount of design thinking. It is currently our best (and only) solution to the problem that doesn't require massive internal reworks and/or compromised UX. We are still free to design new things and I don't think keeping this in meaningfully limits that conversation. And I doubt we will see anything better that doesn't:
None of these are likely to happen any time soon. |
Alright, I'm relatively convinced: I'm in favor of leaving this in for now; I'll chew on how we could better document and expose this API. Thanks for providing context on the design; that was very much missing for the rest of us I think. |
I agree that it would be nice to have dynamic loading in the future, but the current version is missing safety guards like checking that the dynamic feature of bevy is used and that the bevy version matches and is compiled with the same rustc version. In addition I think the api exposed to create plugins is not the right api. So for the time being I think we shouldn't pretend that we have builtin support when it is only half implemented. |
I agree that the safety checks you mentioned are important. Checking for the dynamic feature seems like a relatively straightforward iterative change (export a const in the top level bevy crate that is true when dynamic and false otherwise. we could then throw that in a default function impl for a DynamicPlugin trait, also exported from the top level bevy crate). Unless I'm missing something, checking the rustc version would be a bit more involved, as it would require incorporating build scripts to store the environment / compiler info in a rust file, which could then be built into the binary. But every solution I can think of atm would still require "trusting" the user to implement the dynamic trait apis correctly for the crate / use the safety tools we provide them. This type of dynamic loading seems like it will always have a level of unsafety to it. It feels like the best we can do is provide as many safety nets as possible / push users in the right direction. I personally think these could be iterative improvements to what we have now, given that the fundamental approach used wouldn't be changing. So my current take is this: if somebody is going to pick up the ball now to tackle implementing a safer version of dynamic loading (that doesn't involve massive Bevy rearchitectures or introducing massive user-facing complexity), and their plan is fundamentally incompatible with the approach in this crate, I'm down to remove it now. But if nobody volunteers (or somebody does, but they plan on using the same approach), I'd prefer to leave this as is, add appropriate warnings about safety and constraints asap, and then extend this with additional safety nets as we find strategies that work. |
Assuming bevy is built by cargo, the libbevy_dylib-*.so has a unique name depending on which rustc and bevy version is used. It doesn't help against modified source of a local bevy checkout with identical version number though.
👍 |
Hi ! |
Closing this out for now; I don't think removing this is a priority until we do a proper review of the space. |
It is hard to use the current dynamic plugin system. It doesn't allow
hot code swapping as several OSes don't allow unloading dylibs. It
requires bevy itself to be used as dylib and it requires all other
crates shared between the main game and the plugin to be dylibs.
In the future we may get better plugin support. Whether based on wasm,
or something else. Until then, remove the current dynamic plugin to
avoid making any promises about the current ability to use dynamic
plugins.
If anyone wants to keep using the current dynamic plugin support despite
all it's issues, they can copy the less than 100 lines of code this PR
deletes.