Async Plugin Construction / Plugin Dependencies#18187
Open
SpecificProtagonist wants to merge 10 commits intobevyengine:mainfrom
Open
Async Plugin Construction / Plugin Dependencies#18187SpecificProtagonist wants to merge 10 commits intobevyengine:mainfrom
SpecificProtagonist wants to merge 10 commits intobevyengine:mainfrom
Conversation
Contributor
|
Waiting on a specific plugin to finish would be nice since sometimes you have:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Since the issue was made, Bevy's plugins have been split into three stages that are (typically) run before app update: Build, finish and cleanup. They also have a
readymethod to delay the switch from the build to the finish phase.This allows plugins to delay up to twice while waiting on other plugins, but the specific dependency is implicit even when reading the code and the ordering of plugins matters. Solve this by making plugin building concurrent.
Also, I've just now seen #8607, which also makes plugins asynchronous. I'll need to take a closer look, but afaik it has the goal of running on
bevy_tasksand doesn't address dependencies / plugin ordering (as it build plugins one at a time).Solution
Adds
Plugin::build_async, which runs concurrently for all plugins. The plugin can wait for the world to reach whatever state it needs to continue. While you can define a custom condition, there's also a helper for waiting on a resource; please suggest other ones.This is intended to replace the old plugin lifecycle machinery, which can be deprecated (and eventually removed) in a later PR, which will make things much simpler. As noted in #1255, we'll want to defer app construction actions (like
add_systems); with this PR, the collected actions can be run by turning them into an async plugin.As a followup, we should be able to use a waker and achieve the goals of #8607.
Testing
(TODO: Add plenty of tests if we decide to do this)
Showcase
Migration Guide
(TODO depending on changes)