Skip to content

XGameRuntime: XCL's own XAsync when the system runtime refuses to initialise - #235

Open
ofc0urse wants to merge 1 commit into
xcl-dev:mainfrom
ofc0urse:fix/xgameruntime-init-failure
Open

ofc0urse wants to merge 1 commit into
xcl-dev:mainfrom
ofc0urse:fix/xgameruntime-init-failure

Conversation

@ofc0urse

@ofc0urse ofc0urse commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

When System32\xgameruntime.dll loads but its InitializeApiImpl* calls fail (seen: 0x80073cfc on a Windows 11 machine where the Gaming Services package was not installed, only its service entry), XCL still handed the title the PC runtime's XAsync object. Its first use fails fast inside the system DLL and the title dies about 1.5 s into its boot (Application event log: faulting module xgameruntime.dll, exception 0xc0000409). Seen with a retail title, every run, until Gaming Services was installed.

What is in it

  • crates/xcl/src/hle/xgameruntime/api.rs: a failed InitializeApiImpl* now counts like a missing DLL. pc_object() returns None, so XAsync and XAccessibility take XCL's built-in fallbacks (the path that already exists for machines without the DLL). Their notes say which of the two it is ("no system xgameruntime.dll" or "the system xgameruntime.dll refused to initialise"). When initialisation succeeds nothing changes.
  • Test a_system_runtime_that_refuses_to_initialise_is_not_used: a test-only result for the InitializeApiImpl* calls (FORCED_INIT, cfg(test)) forces the refusal on a PC whose runtime initialises; XAsync and XAccessibility must be XCL's objects. It fails without the change ("XAsync is XCL's"). It holds ASYNC_TEST_LOCK and puts the runtime state back for the other tests.

Tested

  • NVIDIA GeForce RTX 4060 Ti 8 GB (driver 621.24), Intel Core i5-14400F, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0. Tests in debug, runs in release.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on b1f57e3: 681 passed, 0 failed, 41 ignored. SKIPPED on this adapter (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new test with the fix removed from pc_init: fails at the XAsync assertion. With it: passes, and thunk_protocol_with_xcl_objects_on_pc_queues run after it in the same process still gets the PC runtime's XAsync.
  • Before Gaming Services was installed on this PC, main died 1.5 s into the retail title's boot every run and this branch reached the title's menus (earlier head 3ff557d).
  • Other testers on b1f57e3:
    • MesshM, AMD Radeon RX 9060 XT 16 GB (RDNA4), Windows 11: workspace tests pass on the merge with main, 0 SKIPPED, forced-refusal test included (comment).
    • gurvancampion, RTX 5090 under Wine (GE-Proton11-12), where the system runtime refuses with a different result, 0x80040154 (REGDB_E_CLASSNOTREG): without this PR the title dies in xgameruntime.dll at 5.5 s, with it the menus run for the full 75 s (comment).
    • OrangeCrane1738, RTX 5060 Ti on Windows 11 Pro without Gaming Services, where the system runtime refuses with 0x80070424 (ERROR_SERVICE_DOES_NOT_EXIST): without this PR the title stops with a fail-fast (0xc0000409) about 30 s in; with it the fallback is taken and the title runs the full 120 s of a smoke run, 0 crashes, 0 device removals (comment).

Regression run
Both runs on this PC with Gaming Services installed and running, so the system runtime initialises in both and the new path is not taken.

xcl-smoke v1
commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1408 (PresentX 1408)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14577 MB
xcl-smoke v1
commit: b1f57e3e36f1611dece04900148b45a7812c704c
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1391 (PresentX 1391)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14733 MB

Not tested

  • A retail title on AMD (the AMD report ran the tests only).

AI use

  • Claude Code with Claude Opus 5.5: found the cause in the logs, wrote the change, the test, the commit message and this description, ran the tests and the smoke runs. I checked the results on my machine.

🤖 Generated with Claude Code

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested 3ff557d merged onto main 4017f8f (merge c699a09, no conflicts).

There is no test of the refusing path, and one is possible without faking the DLL.

  • The description says so. thunk_protocol_with_xcl_objects_on_pc_queues already drives InitializeApiImplEx2 and the thunks against the system runtime. With a local switch that makes pc_init skip the runtime's entry points and take 0x80073cfc as their result, that test passes on this branch with XAsync: XCL: XUser's async calls complete on XCL's own XAsync. A test-only way to force that result would give the PR its test.
  • I could not reproduce the crash this way. With the same switch and the flag left unset (main's behaviour) the test also passes, with XAsync: PC: here a runtime that was never initialised still hands out a working XAsync. The fail-fast needs a runtime that really refuses.
  • The repository's test title does not reach this code: it logs XGameRuntimeInitialize (XCL offline runtime) and never calls InitializeApiImpl*, so the e2e tests and a smoke run of it say nothing about this change.

From reading: every use of the system runtime's objects goes through pc_object (api.rs 172, 267, 288, 300), so after a failed initialisation XAsync and XAccessibility are XCL's and every class XCL does not implement answers REGDB_E_CLASSNOTREG, as on a PC without the DLL. Two small things:

  • The notes for the two fallbacks still read "(fallback – no system xgameruntime.dll)" when the DLL is there and refused.
  • scripts/pr_check.py on main refuses the description: "the PR's run commits much more memory than main's (14655 MB against 4354 MB)". The description explains why (main's run ends at 1.5 s); the check has no exception for that.

Tested

RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, debug. System32\xgameruntime.dll is present on this PC and initialises.

  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 on the merge c699a09: 652 passed, 0 failed, 40 ignored. SKIPPED on this card: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
  • thunk_protocol_with_xcl_objects_on_pc_queues alone, on the merge plus the local switch (not part of the PR), one process each: runtime as it is, 1 passed (XAsync: PC, the path the description lists as not rerun); forced refusal with the flag left unset, 1 passed (XAsync: PC); forced refusal as in the PR, 1 passed (XAsync: XCL).

Not tested

  • A PC where the system runtime really refuses (0x80073cfc): the refusal above is forced, and the crash the PR fixes did not happen here.
  • The retail game.
  • AMD and Intel.

🤖 Claude Fable 5.2

…tialise

When System32\xgameruntime.dll loads but its InitializeApiImpl* calls fail (seen:
0x80073cfc on a Windows 11 machine where Gaming Services was not installed), XCL still
handed the title the PC runtime's XAsync object. Its first use then fails fast inside
xgameruntime.dll (0xC0000409) and the title dies about a second into its boot.

A failed initialisation now counts like a missing DLL: pc_object() returns None, so
XAsync / XAccessibility take XCL's built-in fallbacks, as they already do without
the DLL. Their notes say which of the two it is.

Test: a_system_runtime_that_refuses_to_initialise_is_not_used forces the refusal through
a test-only result for the InitializeApiImpl* calls (FORCED_INIT) and fails without the
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of b1f57e3e36f1611dece04900148b45a7812c704c on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 702 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 661 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the xgameruntime tests pass, including the forced-refusal path (FORCED_INIT, test-only).

Review: When the system runtime's InitializeApiImpl* fails, XCL's own XAsync is handed out instead of the PC runtime's object that would fail on first use. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@gurvancampion

Copy link
Copy Markdown

Test report for b1f57e3 under Wine, where the system runtime fails with a different HRESULT (0x80040154, REGDB_E_CLASSNOTREG) than the 0x80073cfc in the description. Same outcome: without the PR the title dies in xgameruntime.dll, and with it the title runs.

Tested: RTX 5090 (32-lane waves), NVIDIA 615.78.08, Ryzen 7 9800X3D, Arch-based Linux (kernel 7.2), GE-Proton11-12 (its Wine and vkd3d-proton 3.1). Retail 1.0.2.1, menus only, no input, 75 s per run. The Windows 11 xgameruntime.dll from Gaming Services is copied into the prefix's system32. That copy is how the system runtime gets loaded under Wine. Release builds, MSVC target.

Tree: this is not a clean head. Stock main can't reach this point under Wine without the native-vtable work in #867, so both builds are main 67a3735 plus the same local patches: a subset of #867, the #976 XG stack, and a no-op for ListX slot 101. A is that tree. B is the same tree with this PR merged (api.rs only, no conflicts).

A (without #235) B (with #235)
Init XGameRuntime PC: initialization → 0x80040154 same, – using XCL's own XAsync / fallbacks
XAsync → XAsync: PC → XAsync: XCL (fallback – the system xgameruntime.dll refused to initialise)
Result 0xc0000005 in xgameruntime.dll+0x1098ce (read at address 0x0) at 5.5 s, process ends full 75 s, menus at 30 fps (60 presents per 2 s), 0 unhandled exceptions

Each variant ran once. Not tested: a clean PR head on Windows, and the case where the system runtime initialises (I have no working Gaming Services under Wine).

AI use: Claude Code (Claude Opus 5.5) built the A/B, ran it and wrote this comment. I reviewed it before posting.

@ofc0urse

Copy link
Copy Markdown
Contributor Author

Thanks for the A/B. The fallback is taken for any failed InitializeApiImpl* result, not only 0x80073cfc, so 0x80040154 going the same way is what the change is meant to do. I added your run and the AMD report to the description. Still not covered: a real refusal on Windows with this head, since Gaming Services is installed here now.

(Written with Claude Code, checked by me.)

@OrangeCrane1738

OrangeCrane1738 commented Nov 24, 2026 •

Copy link
Copy Markdown

Real Windows run of this PR's head on a PC without Gaming Services, where the system runtime fails with another HRESULT: 0x80070424 (ERROR_SERVICE_DOES_NOT_EXIST, the service isn't installed).

Tested

  • b1f57e3 as it is (no merge, no local changes), Windows 11 Pro, NVIDIA GeForce RTX 5060 Ti, release build, scripts/smoke.ps1 -Seconds 120, no input. The title: line is the game folder's name, shortened.
  • Without the PR (main 6efdabc on this PC) XAsync goes to the system runtime after the failed initialisation, and the title stops with a fail-fast (0xC0000409) about 30 s in.
  • With it, the log shows the fallback:
    XGameRuntime PC: initialization → 0x80070424 – using XCL's own XAsync / fallbacks
    XAsync: XCL (fallback – the system xgameruntime.dll refused to initialise)
    
    and the title ran the full 120 s:
    xcl-smoke v1
    commit: b1f57e3e36f1611dece04900148b45a7812c704c
    gpu: NVIDIA GeForce RTX 5060 Ti
    title: GTA6.Xbox.v1.0.2.1
    seconds: 120
    exit: 0x0
    frames shown: 977 (PresentX 977)
    presents per 2 s (last 3): 6 5 6
    device removals: 0
    crashes: 0
    peak commit: 15031 MB
    

Not tested

  • A main block from this machine: without this PR, main can't run here, which is the bug.

AI use

  • Claude Opus 5.5 (in the Claude app): read the log and wrote this report. The run was made on my own machine with my own copy; nothing from the game is attached.

icedream added a commit to icedream/xcl that referenced this pull request Nov 25, 2026
Applied from upstream PR xcl-dev#235 (ofc0urse), kept local for testing: with no Gaming
Services on this box the PC runtime is absent anyway, and this makes the
fallback path explicit rather than handing out objects that fail on first use.
icedream added a commit to icedream/xcl that referenced this pull request Nov 25, 2026
Applied from upstream PR xcl-dev#235 (ofc0urse), kept local for testing: with no Gaming
Services on this box the PC runtime is absent anyway, and this makes the
fallback path explicit rather than handing out objects that fail on first use.
@Key-rs

Key-rs commented Nov 25, 2026

Copy link
Copy Markdown

A data point that separates "this PR is needed" from "current main already fixed it", because on one machine both statements can look true depending on the order you do things in.

Machine: Ryzen 7 8845H, RTX 4060 Laptop 8 GB, Windows 11 26300.

Without Microsoft.GamingServices installed

System32\xgameruntime.dll is present (10.0.26100.9656) but InitializeApiImpl fails with 0x80070424. Unmodified main then dies on every run about 1.5 s into boot:

xcl: XGameRuntime: InitializeApiImplEx2 …
xcl: unhandled exception 0xc0000005 in xgameruntime.dll+0x1098ce (read at address 0x0)

(same path as your 0xc0000409, different fault inside the same call.)

With this PR's head merged onto main locally (0aca19f, one file touched, hle/xgameruntime/api.rs), the same package with the same settings ran 30 fps for 16 minutes and presented 14,100 frames, no first-chance exception, no crash log.

After installing Gaming Services 39.118.30001.0

Services GamingServices, GamingServicesNet and XblAuthManager running. Now unmodified main (06c9f55) also does not crash — and the log says why:

XGameRuntime: InitializeApiImplEx2(…) – title goes through the GDK thunks
XGameRuntime: APIs XCL does not implement come from the system xgameruntime.dll
QueryApiImpl … → XAsync: PC

So on this machine the newer main is only fine because the system runtime now initialises; the object it hands over is still the PC one, and the failure mode this PR addresses has simply moved out of reach. Anyone reading "main does not crash any more" as "this PR is redundant" would be reading the environment, not the code.

What I take from that

  • The PR is worth having for the machines that do refuse to initialise, which is not an exotic state: mine was exactly that this morning, with the DLL present and only the service entry missing — the case your description names.
  • If you want a cheap regression check for it later, on a machine with Gaming Services installed the FORCED_INIT path in your test is the only way to keep exercising it; the real-world path will silently stop being tested the moment Gaming Services is present.

Nothing else from me — I only ran it, I did not write it.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants