Add tokio as an optional bevy_tasks backend#6762
Add tokio as an optional bevy_tasks backend#6762james7132 wants to merge 1 commit intobevyengine:mainfrom
Conversation
|
|
||
| let _guard = task_scope_runtime.enter(); | ||
| loop { | ||
| if let Some(result) = self.runtime.block_on(future::poll_once(&mut get_results)) { |
There was a problem hiding this comment.
The primary problem I'm finding is that tokio's block_on does not allow us to internally tick another runtime without blocking. This might be what's causing the deadlock.
|
I would be very happy for |
|
Poked at this some more. So my current branch only allows one local executor to run in the whole task pool. https://github.com/hymm/bevy/tree/tokio. This breaks the 2 thread locality tests, since they need to run a local executor on every thread. Bevy is able to run ok though, since it doesn't actively use that functionality. I have a way of running multiple local executors, but it breaks when scopes are nested and the inner scope tries to tick it's local executor. Tokio complains about running one executor inside of another one. We need nested scopes since we use them when running par_for_each inside of a system. There are a couple possible fixes for this that I can see.
|
|
Backlog cleanup: nice idea, but still a WIP since 2022, so probably safe to close for now. @ me if I'm wrong! :) |
Objective
tokiois the de facto ecosystem standard async executor for the Rust ecosystem. It was initially avoided as it doesn't support all of the target systems that Bevy aims to support (i.e. WASM).Solution
Add an optional feature flag for enabling
tokioas a backing async executor for non-WASM platforms, and enable it by default for them. Usetokio::runtime::Runtimeas a replacement forasync_executor.Note: this change conflicts heavily and is mutually exclusive with #4740. Additional care will needed to be taken to support all of the use cases of both options.
This PR is in a draft state as it currently deadlocks on something during normal program execution. This will need some investigation.
Changelog
Added:
tokioas an optional and default backend async executor for non-WASM platforms.