Skip to content

task runs on wasm but on native, task is scheduled but never runs #20557

@bananaturtlesandwich

Description

@bananaturtlesandwich

Bevy version: 0.16.1

OS: Windows 10

What you did

This is a bit of a weird one because I could have sworn it used to work and it still works on wasm. I'm spawning a future on the IoTaskPool like so (the future is a bsky api request and compat allows tokio compatibility):

bevy::tasks::IoTaskPool::get().spawn(Compat::new(
    CLIENT.service.app.bsky.actor.get_profile(
        get_profile::ParametersData {
            actor: actor.clone(),
        }
        .into(),
    ),
))

I then have a separate system running which polls the task in the Update Schedule

    match ask.task.as_mut().and_then(|task| bevy::tasks::block_on(
      bevy::tasks::futures_lite::future::poll_once(task)
    )) {
        Some(Ok(profile)) => ...
        Some(Err(e)) => ...
        None => return,
    }
    ask.task = None;

What went wrong

this is working perfectly on wasm! however on native builds the task never finishes. If I debug print the task then I get

Task(
    Task {
        header: Header {
            scheduled: true,
            running: false,
            completed: false,
            closed: false,
            awaiter: false,
            task: true,
            ref_count: 2,
            metadata: (),
        },
    },
)

which I think means it's been scheduled but never gets run which is very bizarre.
Unsure on what could be happening here

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-TasksTools for parallel and async workC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions