-
-
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
Restrict available methods on App from Plugin::Build() #4231
Comments
Related to #1255, #2160 and bevyengine/rfcs#33. My preference is to remove the There are a fixed number of things plugins can do (add systems, initialize types, add resources, set the runner, ...) and we could have defaulted trait methods to allow end users to only specify the properties that they wish to set. That approach eliminates this footgun, enables order-independence, and makes it clearer to users how plugins are meant to be used. |
That said, I think that simply passing ownership to |
This would make it impossible to do either Maybe |
…bevyengine#4241) # Objective Fixes bevyengine#4231. ## Solution This PR implements the solution suggested by @bjorn3 : Use an internal property within `App` to detect `App::run()` calls from `Plugin::build()`. --- ## Changelog - panic when App::run() is called from Plugin::build()
…bevyengine#4241) # Objective Fixes bevyengine#4231. ## Solution This PR implements the solution suggested by @bjorn3 : Use an internal property within `App` to detect `App::run()` calls from `Plugin::build()`. --- ## Changelog - panic when App::run() is called from Plugin::build()
What problem does this solve or what need does it fill?
When implementing a
Plugin
, a user has some footgun available:App::run()
, would result in an early launch of the app, handled by plugin, resulting in a partly initialized app to run. On discord a user had this problem and it was not so trivial to track. See final fix there: Sheepyhead/prepare_two_die@3586bcd#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L29What solution would you like?
Ordered from my personal preferred to less preferred:
If there are no uses to run an App from a
Plugin::Build
, a user shouldn't be able to, we could either:Plugin::Build
because we have a&mut App
.App::run()
and other footguns being available within thePlugin::Build()
function body.If there exists reasons (I'm curious to hear about them) to indeed run an app from a plugin, we could either:
build_advanced
allowing such rare behaviour ?ReportExecutionOrderAmbiguities
to offer advanced diagnostics.The text was updated successfully, but these errors were encountered: