Skip to content

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

Closed
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:xgameruntime/xuser-association-canceled
Closed

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:xgameruntime/xuser-association-canceled

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

…e sign-in check

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 the AssociationCall allocation.

In addition, XUserRegisterForDeviceAssociationChanged pushed to
ASSOCIATION_CALLBACKS and read 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.

Skip invoking the guest callback when `canceled` is true, and read/set
USER_SIGNED_IN while holding ASSOCIATION_CALLBACKS so each registration
is notified once.

Assisted-by: OpenCode (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

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.

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

@b3IKK b3IKK closed this Nov 25, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

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

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.

2 participants