XGameRuntime: skip canceled device association callbacks and serialize sign-in check #1222

Closed
b3IKK wants to merge 1 commit from upstream-pr/1231 into main
b3IKK commented 2026-11-24 13:26:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T13:26:27Z.


association_call ignored the task queue's canceled parameter, so terminating the queue before dispatching still invoked the guest's XUserDeviceAssociationChangedCallback on a terminated queue instead of only dropping Box<AssociationCall>.

In addition, XUserRegisterForDeviceAssociationChanged pushed to ASSOCIATION_CALLBACKS and checked USER_SIGNED_IN outside the lock while user_signed_in() swapped USER_SIGNED_IN before locking, allowing a concurrent sign-in and registration to deliver the same callback twice.

This skips invoking the guest callback when canceled is true and reads/sets USER_SIGNED_IN while holding ASSOCIATION_CALLBACKS.

What is in it

  • crates/xcl/src/hle/xgameruntime/mod.rs: return without invoking the guest callback in association_call when canceled is true; check/set USER_SIGNED_IN under ASSOCIATION_CALLBACKS.lock(); add unit test device_association_callback_not_invoked_when_queue_terminated (verified failing before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib device_association_callback_not_invoked_when_queue_terminated: 1 passed, 0 failed (failed before the fix with callback invoked once on queue termination)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 8947c81d6f61904dc3da59acb4968ac9e76ef0f6
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14598 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited xgameruntime/mod.rs, wrote the fix and regression test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:6582825489 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1231). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T13:26:27Z. --- `association_call` ignored the task queue's `canceled` parameter, so terminating the queue before dispatching still invoked the guest's `XUserDeviceAssociationChangedCallback` on a terminated queue instead of only dropping `Box<AssociationCall>`. In addition, `XUserRegisterForDeviceAssociationChanged` pushed to `ASSOCIATION_CALLBACKS` and checked `USER_SIGNED_IN` outside the lock while `user_signed_in()` swapped `USER_SIGNED_IN` before locking, allowing a concurrent sign-in and registration to deliver the same callback twice. This skips invoking the guest callback when `canceled` is true and reads/sets `USER_SIGNED_IN` while holding `ASSOCIATION_CALLBACKS`. **What is in it** - `crates/xcl/src/hle/xgameruntime/mod.rs`: return without invoking the guest callback in `association_call` when `canceled` is true; check/set `USER_SIGNED_IN` under `ASSOCIATION_CALLBACKS.lock()`; add unit test `device_association_callback_not_invoked_when_queue_terminated` (verified failing before the fix). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib device_association_callback_not_invoked_when_queue_terminated`: 1 passed, 0 failed (failed before the fix with callback invoked once on queue termination) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: 8947c81d6f61904dc3da59acb4968ac9e76ef0f6 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14598 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `xgameruntime/mod.rs`, wrote the fix and regression test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
DavidM1911 commented 2026-11-24 14:06:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:47:25Z.


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

  • cargo test -p xcl --lib xgameruntime: 74 passed, 0 failed.

Note: the full d3d12x lib filter currently aborts with 0xc0000005 on unmodified main too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.

<!-- greyfinch-sync:ivall/xcl:comment:7133339997 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1231#issuecomment-7133339997). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:47:25Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib xgameruntime: 74 passed, 0 failed. Note: the full `d3d12x` lib filter currently aborts with 0xc0000005 on unmodified `main` too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.
upstream-sync closed this pull request 2026-11-25 00:07:15 +00:00
b3IKK commented 2026-11-25 00:09:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-25T00:04:59Z.


Closing in favour of #1753, this account's later PR on the same callbacks (#1607, group D58). #1753's association_call already skips a call the queue canceled, which is the first half of this PR, and also cancels queued calls on unregister. The second half here (reading the sign-in flag under the callbacks lock) is what #1418 and #1583 do more completely. AI use: OpenCode, Claude Fable 5.2.

<!-- greyfinch-sync:ivall/xcl:comment:7148118466 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1231#issuecomment-7148118466). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-25T00:04:59Z. --- Closing in favour of #1753, this account's later PR on the same callbacks (#1607, group D58). #1753's `association_call` already skips a call the queue canceled, which is the first half of this PR, and also cancels queued calls on unregister. The second half here (reading the sign-in flag under the callbacks lock) is what #1418 and #1583 do more completely. AI use: OpenCode, Claude Fable 5.2.
DavidM1911 commented 2026-11-26 05:05:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:17:20Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7182462759 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1231#issuecomment-7182462759). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:17:20Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1222
No description provided.