bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
33.47k stars 3.26k forks source link

Sysinfo plugin does not compile without `multi_threaded` feature #13957

Open Friz64 opened 1 week ago

Friz64 commented 1 week ago

Bevy version

Any version after #13693

What you did

Compiled bevy without the multi_threaded feature, but with the sysinfo_plugin feature

What went wrong

error[E0308]: mismatched types
    --> crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs:147:30
     |
147  |             tasks.tasks.push(task);
     |                         ---- ^^^^ expected `Task<SysinfoRefreshData>`, found `FakeTask`
     |                         |
     |                         arguments to this method are incorrect
     |
     = note: expected struct `Task<SysinfoRefreshData>`
                found struct `FakeTask`
note: method defined here
    --> /home/friz64/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:1993:12
     |
1993 |     pub fn push(&mut self, value: T) {
     |            ^^^^
bugsweeper commented 1 week ago

That because single_threaded_task_pool::TaskPool::spawn returns FakeTask which can't contain future result, because it's just empty struct, but actualy for non wasm (for wasm it indeed can't do better, because uses wasm spawn method which allows only futures which outputs only empty tuple) it spawns future, gets it's task, waits while executor finishes, and return nothing (FakeTask), throwing away _task with result! I think should be two spawn implementations for wasm (returning empty FakeTask) and for non-wasm which would return ready result T.