Skip to content
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

C#: Tasks don't work in exported projects with AOT. #87596

Closed
zaevi opened this issue Jan 25, 2024 · 0 comments · Fixed by #87597
Closed

C#: Tasks don't work in exported projects with AOT. #87596

zaevi opened this issue Jan 25, 2024 · 0 comments · Fixed by #87597

Comments

@zaevi
Copy link
Contributor

zaevi commented Jan 25, 2024

Tested versions

4.x

System information

Win11

Issue description

When export with AOT, all tasks don't work.

It seems when initializing with AOT, runtime_initialized isn't assigned to true, which prevents firing ScriptManagerBridge.FrameCallback() and GodotTaskScheduler won't work.

Consider the code in MRP:

public override async void _Ready()
{
    var log = GetNode<RichTextLabel>("Log");
    log.AddText($"IsRuntimeInitialized: {GodotSharp.IsRuntimeInitialized()}\n");
    for (var i = 1; i <= 10; i++)
    {
        await Task.Delay(1000);
        log.AddText($"{i} ");
    }
}

Run in editor, and it prints as expected:

IsRuntimeInitialized: True
1 2 3 4 5 6 7 8 9 10

Run exported executable with AOT, it prints IsRuntimeInitialized: False and won't continue counting.

Activating GodotTaskScheduler manually will make tasks works:

public override void _Process(double delta)
{
    (TaskScheduler.Default as GodotTaskScheduler)?.Activate();
}

Steps to reproduce

Use MRP below.

Minimal reproduction project (MRP)

aot_task_test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants