Skip to content

Game Studio freezes under Wine/Proton: GC cannot suspend Dispatcher.ForBatched busy-wait (.NET 9+)Β #3599

Open

Description

@pm-lucarohde

Release Type: Official Release

Version: 4.4.0 (Stride.GameStudio NuGet package)

Platform(s): Linux, Game Studio running through Wine/Proton (Fedora Kinoite 44, GE-Proton11-6 = Wine 11.0 Staging, Windows .NET runtime 10.0.13 in the prefix)

Describe the bug
Roughly 30–45 seconds after opening a project, Game Studio freezes completely (no UI updates, thumbnails stop building). It never recovers.

Memory dumps of the frozen process show:

  • one thread inside a GC (!clrthreads marks it (GC)), spinning in coreclr's thread suspension loop,
  • exactly one other managed thread still in cooperative mode, busy-waiting in Dispatcher.ForBatched β†’ ThreadPool.TryCooperate().

Root cause: since .NET 9, CoreCLR on Windows suspends threads for a GC by injecting a special user-mode APC (QueueUserAPC2 with QUEUE_USER_APC_FLAGS_SPECIAL_USER_APC). Under Wine, that APC is not delivered to a thread that spins in user code without making a system call. The busy-wait in Dispatcher.ForBatched (sources/core/Stride.Core/Threading/Dispatcher.cs, the while (... ) ThreadPool.Instance.TryCooperate(); loop) never makes a syscall while the queue is empty, so the GC waits for it forever and the editor deadlocks.

This is primarily a Wine bug, but Stride can avoid it cheaply (see PR #3600), which would make Game Studio usable through Proton as advertised for 4.4.

To Reproduce

  1. Run Game Studio 4.4.0 under GE-Proton11-6 (also reproduced with Valve Proton 11, Proton Experimental and proton-cachyos; with ntsync and with fsync).
  2. Open a project (e.g. the FPS template).
  3. After ~30–45 s the editor freezes.

Minimal repro without Stride (console app, net10.0, run with the Windows .NET runtime under Wine):

using System.Collections.Concurrent;

// One thread busy-waits like Stride's Dispatcher.ForBatched (TryCooperate loop),
// the main thread forces GCs. "spin" hangs under Wine with .NET 9+, "spinwait" does not.
var mode = args.Length > 0 ? args[0] : "spin";
var queue = new ConcurrentQueue<int>();
var stop = false;

new Thread(() =>
{
    var spinWait = new SpinWait();
    while (!Volatile.Read(ref stop))
    {
        bool worked = queue.TryDequeue(out _);
        if (mode == "spinwait")
        {
            if (worked) spinWait.Reset();
            else spinWait.SpinOnce(sleep1Threshold: -1);
        }
    }
}) { IsBackground = true }.Start();

Thread.Sleep(500);
for (int i = 0; i < 20; i++)
{
    GC.Collect();
    Console.WriteLine($"{mode}: GC {i + 1}/20 done");
}
Volatile.Write(ref stop, true);
Console.WriteLine($"{mode}: OK");

Results under GE-Proton11-6 (Wine 11.0 Staging):

Variant .NET 8 .NET 9 .NET 10.0.13
spin (busy-wait like ForBatched) 20/20 GCs 0/20 (hangs) 0/20 (hangs)
spinwait (SpinWait.SpinOnce when idle) – – 20/20 GCs
busy-wait calling Thread.Yield() / WaitOne(0) – – 20/20 GCs

The while (... && !Finished.WaitOne(0)) TryCooperate(); loop further down in Dispatcher.cs is not affected, because WaitOne(0) is a syscall.

Expected behavior
Game Studio keeps working; GCs complete.

Log and callstacks
Frozen state from the dumps: GC thread spinning in coreclr.dll thread suspension; the only cooperative thread is in Stride.Core.Threading.Dispatcher.ForBatched β†’ Stride.Core.Threading.ThreadPool.TryCooperate.

Additional context

  • Confirmation of the root cause: forcing CoreCLR to use the pre-.NET 9 suspension path (by making the QueueUserAPC2 lookup fail in coreclr.dll) removes the freeze completely. 2/2 five-minute Game Studio sessions ran without a freeze, all thumbnails were built, and the scene rendered. This is only a local workaround, not something Stride can ship.
  • Related tracking issue: Proton/Steam Deck compatibilityΒ #3419

Activity

  1. added
    bug
    on Oct 15, 2026
  2. xen2 commented on Oct 26, 2026

    @xen2
    Member

    Another possible candidate: RootRenderFeature.GetOrCreateObjectNode has an empty while (Volatile.Read(...) == -2) { } spin.
    The thread it waits on calls objectNodes.Add, which can allocate and trigger a GC, so it could hit the same problem.

  3. added
    area-Core
    platform-Linux
    on Oct 31, 2026
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

    area-Corearea-GameStudiobugplatform-Linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions