Skip to content

Multithreaded world causes deadlock in Godot #2

Closed

Description

@tvenclovas96

Trying to step with B2Api.b2DefaultWorldDef_WithDotNetTpl() causes a deadlock in Godot C#. This is due to the engine providing it's own SynchronizationContext which forces continuations on the main thread.

Adding .ConfigureAwait(false) here seems sufficient

await Task.WhenAll(tasks);

(As a sidenote, the Task.Factory.StartNew just above the mentioned line could also be replaced with a Task.Run, which would be a more "canonical" choice)

Activity

  1. thomasvt commented on Jun 13, 2025

    @thomasvt
    Owner

    Thanks for the suggestion. I'll test this out a bit this weekend and change it if it turns out ok.

  2. thomasvt commented on Jun 15, 2025

    @thomasvt
    Owner

    Your suggestion is now included as of 3.1.6.

    Please note that there already is a 3.1.7, containing an update for the latest Box2D.

  3. tvenclovas96 commented on Jun 15, 2025

    @tvenclovas96
    ContributorAuthor

    Cheers! Thank you for the great lib, as well!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions