XGameRuntime: XCL's own XAsync when the system runtime refuses to initialise #232
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/235"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by ofc0urse on 2026-11-23T21:41:15Z.
When
System32\xgameruntime.dllloads but itsInitializeApiImpl*calls fail (seen:0x80073cfcon a Windows 11 machine where the Gaming Services package was not installed, only its service entry), XCL still handed the title the PC runtime'sXAsyncobject. Its first use fails fast inside the system DLL and the title dies about 1.5 s into its boot (Application event log: faulting modulexgameruntime.dll, exception0xc0000409). Seen with a retail title, every run, until Gaming Services was installed.What is in it
crates/xcl/src/hle/xgameruntime/api.rs: a failedInitializeApiImpl*now counts like a missing DLL.pc_object()returnsNone, soXAsyncandXAccessibilitytake 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.a_system_runtime_that_refuses_to_initialise_is_not_used: a test-only result for theInitializeApiImpl*calls (FORCED_INIT,cfg(test)) forces the refusal on a PC whose runtime initialises;XAsyncandXAccessibilitymust be XCL's objects. It fails without the change ("XAsync is XCL's"). It holdsASYNC_TEST_LOCKand puts the runtime state back for the other tests.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onb1f57e3: 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.pc_init: fails at theXAsyncassertion. With it: passes, andthunk_protocol_with_xcl_objects_on_pc_queuesrun after it in the same process still gets the PC runtime'sXAsync.maindied 1.5 s into the retail title's boot every run and this branch reached the title's menus (earlier head3ff557d).b1f57e3:main, 0SKIPPED, forced-refusal test included (comment).0x80040154(REGDB_E_CLASSNOTREG): without this PR the title dies inxgameruntime.dllat 5.5 s, with it the menus run for the full 75 s (comment).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.
Not tested
AI use
🤖 Generated with Claude Code
upstream-sync referenced this pull request2026-11-24 06:59:48 +00:00
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T00:12:43Z.
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.
thunk_protocol_with_xcl_objects_on_pc_queuesalready drivesInitializeApiImplEx2and the thunks against the system runtime. With a local switch that makespc_initskip the runtime's entry points and take 0x80073cfc as their result, that test passes on this branch withXAsync: 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.XAsync: PC: here a runtime that was never initialised still hands out a working XAsync. The fail-fast needs a runtime that really refuses.XGameRuntimeInitialize (XCL offline runtime)and never callsInitializeApiImpl*, 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.rs172, 267, 288, 300), so after a failed initialisationXAsyncandXAccessibilityare XCL's and every class XCL does not implement answersREGDB_E_CLASSNOTREG, as on a PC without the DLL. Two small things:scripts/pr_check.pyon 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.dllis present on this PC and initialises.cargo build --workspace, thencargo test --workspace -- --test-threads=4on the merge c699a09: 652 passed, 0 failed, 40 ignored. SKIPPED on this card:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).thunk_protocol_with_xcl_objects_on_pc_queuesalone, 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
🤖 Claude Fable 5.2
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T04:33:53Z.
Test run of
b1f57e3e36f1611dece04900148b45a7812c704con AMD RDNA4. I merged it onto currentmain64b3f35locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED; thexgameruntimetests pass, including the forced-refusal path (FORCED_INIT, test-only).Review: When the system runtime's
InitializeApiImpl*fails, XCL's ownXAsyncis 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 ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172Imported from ivall/xcl. Originally posted by gurvancampion on 2026-11-24T14:02:27Z.
Test report for
b1f57e3under Wine, where the system runtime fails with a different HRESULT (0x80040154,REGDB_E_CLASSNOTREG) than the0x80073cfcin the description. Same outcome: without the PR the title dies inxgameruntime.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.dllfrom Gaming Services is copied into the prefix'ssystem32. That copy is how the system runtime gets loaded under Wine. Release builds, MSVC target.Tree: this is not a clean head. Stock
maincan't reach this point under Wine without the native-vtable work in #867, so both builds aremain67a3735plus 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.rsonly, no conflicts).XGameRuntime PC: initialization → 0x80040154– using XCL's own XAsync / fallbacksXAsync→ XAsync: PC→ XAsync: XCL (fallback – the system xgameruntime.dll refused to initialise)0xc0000005 in xgameruntime.dll+0x1098ce (read at address 0x0)at 5.5 s, process ends60 presentsper 2 s), 0 unhandled exceptionsEach 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.
Imported from ivall/xcl. Originally posted by ofc0urse on 2026-11-24T17:00:38Z.
Thanks for the A/B. The fallback is taken for any failed
InitializeApiImpl*result, not only0x80073cfc, so0x80040154going 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.)
Imported from ivall/xcl. Originally posted by OrangeCrane1738 on 2026-11-24T17:18:14Z.
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
b1f57e3as it is (no merge, no local changes), Windows 11 Pro, NVIDIA GeForce RTX 5060 Ti, release build,scripts/smoke.ps1 -Seconds 120, no input. Thetitle:line is the game folder's name, shortened.6efdabcon 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.Not tested
mainblock from this machine: without this PR,maincan't run here, which is the bug.AI use
Imported from ivall/xcl. Originally posted by Key-rs on 2026-11-25T15:15:44Z.
A data point that separates "this PR is needed" from "current
mainalready 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.GamingServicesinstalledSystem32\xgameruntime.dllis present (10.0.26100.9656) butInitializeApiImplfails with0x80070424. Unmodifiedmainthen dies on every run about 1.5 s into boot:(same path as your
0xc0000409, different fault inside the same call.)With this PR's head merged onto
mainlocally (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,GamingServicesNetandXblAuthManagerrunning. Now unmodifiedmain(06c9f55) also does not crash — and the log says why:So on this machine the newer
mainis 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
FORCED_INITpath 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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:19:39Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by AngeloMaiale on 2026-11-25T22:44:43Z.
Tested
#235(b1f57e3e36f1) merged cleanly ontomain(689f2db477c3, merge commit2e7dcd39d975) on a native Windows 11 Home machine without theMicrosoft.GamingServicespackage installed (Get-AppxPackage *GamingServices*empty).On this machine
System32\xgameruntime.dllfails bothInitializeApiImplEx2calls with0x80040154(REGDB_E_CLASSNOTREG) — confirming that0x80040154occurs on native Windows 11 too, not only under Wine. Onmain(689f2db477c3) the retail title crashes deterministically at 19.3 s with0xc0000005insidexgameruntime.dll+0x107fae(read at address 0x0) right after the second failedInitializeApiImplEx2. With#235merged,XAsyncandXAccessibilityswitch to XCL's built-in fallbacks and the title runs the full 60 s smoke window with 0 crashes and 0 device removals.Tested
rustc 1.100.0, DXC1.9.2609.5(tests in debug, smoke runs in release).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4) on2e7dcd39d975: 976 passed, 0 failed, 45 ignored (a_system_runtime_that_refuses_to_initialise_is_not_usedpasses)SKIPPEDGPU tests/subcases on this wave32 adapter: 18no wave64(a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware, plus 11 wave64 subcases inlower_dxil::tests), 3 wave32 per-lane f16 refusals (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 1no heap windowsRegression run
main (
689f2db477c3):#235merged ontomain(2e7dcd39d975):Not tested
Microsoft.GamingServicesinstalled on this PCAI use
xcl.log, and drafted this test report.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:43:36Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:33:03Z.
merge-check claim
head:
b1f57e3e36Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:40:39Z.
merge-check
base:
cfb9753a8chead:
b1f57e3e36merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2835 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. The PR's new test a_system_runtime_that_refuses_to_initialise_is_not_used ran (this PC has System32\xgameruntime.dll) and passed; the log shows "initialization → 0x80073cfc – using XCL's own XAsync / fallbacks" and both fallbacks chosen with the new reason.
review: no blocking finding; whole diff read (one file). A failed InitializeApiImpl* now sets PC_INIT_FAILED, so pc_object answers None from then on: XAsync and XAccessibility take XCL's existing fallbacks, start_pc_async no longer hands xasync the system object, and other families the PC runtime would have served answer "missing", where today the title gets objects that fail fast inside xgameruntime.dll (the crash three testers in the thread reproduced). main still has no equivalent (pc_init only logs the failure). The test-only FORCED_INIT hook is cfg(test), so release code always calls the real entry points. The flags are process-wide: the test holds ASYNC_TEST_LOCK and resets both on drop; of the other tests in api.rs that query the runtime without that lock, none reaches a family the PC runtime serves (XPackage is XCL's own; the accessibility test uses the fallback object directly). Minor: PC_INIT_FAILED is never cleared, so a title that called the initialisation a second time and succeeded would still get the fallbacks. No other PR handles a refusing runtime.
performance: none (start-up path only).
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T06:12:15Z.
merge-check claim
head:
b1f57e3e36Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T06:25:50Z.
merge-check
base:
d52ff48caahead:
b1f57e3e36merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2876 passed, 2 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
correction: this check first reported the PR as "not yet" because of a test failure that is not the PR's. The base-comparison step failed to run (test names contain a double colon, not a legal Windows filename), so an empty read was mistaken for "passes on base".
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16fails on based52ff48cby itself (verified separately with the same command: "assertion failed: 2D D16 resinfo clobbered v2/v3"). Verdict corrected. Apologies for the noise.Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T09:05:37Z.
merge-check
base:
bc4503d428head:
b1f57e3e36merge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2878 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16("2D D16 resinfo clobbered v2/v3", left (0, 0)), which fails the same way on the base alone: 2877 passed, 1 failed, 51 ignored, same test. The new testa_system_runtime_that_refuses_to_initialise_is_not_usedran here (System32\xgameruntime.dll is present and initialises) and passed. It is a real regression test on this machine: with thePC_INIT_FAILED.store(true, ...)line inpc_initcommented out in the merged tree,cargo test -p xcl --lib hle::xgameruntime::api::tests::a_system_runtime_that_refuses_to_initialise_is_not_used -- --test-threads=1fails at "XAsync is XCL's".review: whole diff read (+70/-6,
hle/xgameruntime/api.rs). A failedInitializeApiImpl*setsPC_INIT_FAILED;pc_objectthen answersNone, sostart_pc_asyncnever callsxasync::use_pcwith the system object,QueryApiImplhands out XCL's XAsync and XAccessibility (the existing no-DLL fallbacks), and other families the system runtime would serve answerREGDB_E_CLASSNOTREG. When the runtime initialises nothing changes: the flag is only set onhr < 0, and the smoke log below still showsXAsync: PC.FORCED_INITiscfg(test), so release builds always call the real entry points. Notes, none a blocker: (1) objects whosepcpointer was cached before the failed initialisation (QueryApiImplcacheso.pcfor forwarding classes,forward_alias_obj) keep the system pointer; this only matters for a title that queries before it initialises. (2) The flag is never cleared, and a first successful init followed by a failed second one would leavexasync::use_pcon the system object whileQueryApiImplgives XCL's XAsync. Titles call the initialisation once, so I do not expect either case. (3)UninitializeApiImplstill calls the system runtime's uninitialise after a refused init, asmaindoes today. (4) Without the DLL the new test prints "skipping" and passes, with noSKIPPEDline. Of the open PRs that touchapi.rs(#1220, #1610, #1615, #2957), none changespc_initor adds this fallback.performance: start-up path only. Measured with
scripts/smoke.ps1, 60 s of a retail title, release, after one warm-up run of the base: 1699 frames and 15476 MB peak commit against 1652 frames and 15598 MB on the base (warm-up: 1476, 15343 MB). No device removal, no crash. Gaming Services is installed on this PC, so the system runtime initialises and the new path was not taken in these runs.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, test and smoke, reviewed the diff against the merged source and wrote this)