gdk rt: XAsyncGetStatus(wait) waits for the completion callback, as the PC runtime does #210

Closed
github-bot wants to merge 3 commits from gh-pr/210/head into gh-pr/210/base
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 02:04 UTC · original
QuentinDanblon:fix/xasync-wait → main · +379 −22 · 3 files · 3 commits · closed without merging

Library / area: compat-common, gdk/rt.rs (emulated XAsync)

Exports changed (exports.txt rows): none

Source of the behaviour: measured on the PC xgameruntime.dll 10.0.26100.9656 (System32, loaded directly, thread-pool queue). This is the PC runtime, not a console. The result matches the design of libHttpClient's AsyncLib (MIT), which I used to understand the measurements; no code taken from it.

One topic: when XAsyncGetStatus(wait = true) returns. rt.rs only, +27 / -20, plus a 208-line test file.

What was wrong

get_status(wait) looped on the status. complete() sets the status first, then queues the completion callback, and only notifies after the callback. So:

  1. A waiter that arrives after XAsyncComplete of a call with a result returned at once, while the callback was still running. The PC runtime returns after the callback has returned.
  2. complete() wrote the block (mark) after the status was visible, with the provider's Cleanup in between. A waiter could return and then see the block change.

Measurements (12 runs per case, callback sleeps 60 ms)

case PC runtime main ad24144 this PR
no result, waiter starts while pending after the callback, 12 / 12 same same
no result, waiter arrives after completion before the callback, 12 / 12 same same
result of 4 bytes, waiter starts while pending after the callback, 12 / 12 same same
result of 4 bytes, waiter arrives after completion after the callback, 12 / 12 before, 12 / 12 after, 12 / 12
completed with E_ABORT from the Cancel op, then wait before the callback, 12 / 12 same same
Cleanup sleeps 200 ms, wait during it returns during Cleanup, block unchanged afterwards, 5 / 5 block changes after the wait returned block unchanged, 5 / 5
wait from inside the callback, no result returns, 12 / 12 same same
wait from inside the callback, result of 4 bytes does not return (1.5 s timeout), 12 / 12 returns does not return
manual completion port that nobody dispatches, result of 4 bytes, waiter starts while pending (completed from another thread) does not return in 1.5 s and does not run the callback itself; returns once another thread dispatches the port, 5 / 5 same same
same, waiter arrives after completion does not return until another thread dispatches, 5 / 5 returns at once, 5 / 5 does not return until dispatched
manual completion port, no result, waiter starts while pending does not return until another thread dispatches, 5 / 5 same same
manual completion port, no result, waiter arrives after completion returns at once, callback left queued, 5 / 5 same same

The row about waiting from inside the callback is a consequence of the fourth and I left it faithful: a title cannot depend on a hang. If you would rather return there, say so and I will add the exception.

Manual completion port (added after your question): the PC runtime never dispatches from inside the wait. A thread that waits on a call with a result and is the only one pumping the completion port blocks there on the PC runtime, and it already blocks on main when the wait started while the call was pending. This PR changes only the "arrives after completion" row, to what the PC runtime does.

The change

  • AState gets a signaled flag, raised after the completion callback (or at completion when there is none, or when the queue is invalid). get_status(wait) waits for it.
  • A call without a result leaves the state table at completion, under the status lock, in the same critical section as the status and the block marker. A waiter that sees a final status therefore finds either no state (returns at once) or the signal.
  • The table entry is removed only if it is still this call's (Arc::ptr_eq). Before, the removal ran after the callback, so a callback that began a new call on the same block lost the new state.
  • complete() reads the callback pointer inside the same critical section and does not touch the block afterwards.

Cost: one atomic load per get_status(wait), one extra short lock per completion. No change on the non-waiting path.

Tests

tests/gdk_xasync_wait.rs, six cases through the interface slots:

test main ad24144 this PR
wait_on_a_completed_call_with_a_result_returns_after_the_callback fails every run passes
block_is_not_written_after_wait_returns fails every run passes
wait_on_a_completed_call_without_a_result_does_not_wait_for_the_callback passes passes
wait_started_while_pending_returns_after_the_callback passes passes
wait_does_not_pump_a_manual_completion_queue fails every run (the "after completion" half) passes
wait_on_a_completed_call_without_a_result_leaves_the_callback_queued passes passes

cargo test -p compat-common --release --no-fail-fast on ad24144 plus the first commit: 233 passed, 1 failed, 11 ignored. After the second commit (tests only) I reran the test file alone: 6 passed, 5 runs out of 5. The failure is gdk_multi_dll, which did not get as far as running: its nested cargo build drops every TOMBOX_* variable, this machine has no Windows SDK DXC outside TOMBOX_DXC_DIR, and shaders/query_accum.dxil is not in the tree, so the d3d12_xs build script stops. Not related to this change. With the two-line fix of #212 on top, gdk_multi_dll passes here with this PR's rt.rs (1 passed).

Also run with the conformance scenarios of the old #48 on top (not in this PR, I will resubmit them separately as you asked): the default set passes 8 times out of 8, and verify_wait_for_completion, run alone 20 times, goes from 16 / 20 to 20 / 20.

Not in this PR

Measured in passing, left alone because it is a different topic and it changes what a provider must do: after XAsyncCancel, the PC runtime leaves the call pending until the provider completes it (status E_PENDING right after a cancel that the provider ignores, then the provider's own result). rt.rs completes the call itself with E_ABORT. That is why verify_cancellation and the two verify_cleanup_waits_for_work scenarios still differ.

No comment lines added (PR gate: 2 files checked, 0 problems).

  • cargo test -p compat-common --release: 233 passed; gdk_multi_dll could not build on this machine (see above)
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

**@⁠QuentinDanblon** on GitHub · 2026-11-23 02:04 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210) `QuentinDanblon:fix/xasync-wait` → `main` · +379 −22 · 3 files · 3 commits · closed without merging **Library / area:** compat-common, `gdk/rt.rs` (emulated XAsync) **Exports changed (exports.txt rows):** none **Source of the behaviour:** measured on the PC `xgameruntime.dll` 10.0.26100.9656 (System32, loaded directly, thread-pool queue). This is the PC runtime, not a console. The result matches the design of libHttpClient's AsyncLib (MIT), which I used to understand the measurements; no code taken from it. One topic: when `XAsyncGetStatus(wait = true)` returns. `rt.rs` only, +27 / -20, plus a 208-line test file. ### What was wrong `get_status(wait)` looped on the status. `complete()` sets the status first, then queues the completion callback, and only notifies after the callback. So: 1. A waiter that arrives after `XAsyncComplete` of a call **with a result** returned at once, while the callback was still running. The PC runtime returns after the callback has returned. 2. `complete()` wrote the block (`mark`) after the status was visible, with the provider's `Cleanup` in between. A waiter could return and then see the block change. ### Measurements (12 runs per case, callback sleeps 60 ms) | case | PC runtime | main `ad24144` | this PR | |---|---|---|---| | no result, waiter starts while pending | after the callback, 12 / 12 | same | same | | no result, waiter arrives after completion | before the callback, 12 / 12 | same | same | | result of 4 bytes, waiter starts while pending | after the callback, 12 / 12 | same | same | | result of 4 bytes, waiter arrives after completion | **after** the callback, 12 / 12 | **before**, 12 / 12 | after, 12 / 12 | | completed with `E_ABORT` from the `Cancel` op, then wait | before the callback, 12 / 12 | same | same | | `Cleanup` sleeps 200 ms, wait during it | returns during `Cleanup`, block unchanged afterwards, 5 / 5 | block changes after the wait returned | block unchanged, 5 / 5 | | wait from inside the callback, no result | returns, 12 / 12 | same | same | | wait from inside the callback, result of 4 bytes | **does not return** (1.5 s timeout), 12 / 12 | returns | does not return | | manual completion port that nobody dispatches, result of 4 bytes, waiter starts while pending (completed from another thread) | does not return in 1.5 s and does not run the callback itself; returns once another thread dispatches the port, 5 / 5 | same | same | | same, waiter arrives after completion | **does not return** until another thread dispatches, 5 / 5 | returns at once, 5 / 5 | does not return until dispatched | | manual completion port, no result, waiter starts while pending | does not return until another thread dispatches, 5 / 5 | same | same | | manual completion port, no result, waiter arrives after completion | returns at once, callback left queued, 5 / 5 | same | same | The row about waiting from inside the callback is a consequence of the fourth and I left it faithful: a title cannot depend on a hang. If you would rather return there, say so and I will add the exception. Manual completion port (added after your question): the PC runtime never dispatches from inside the wait. A thread that waits on a call with a result and is the only one pumping the completion port blocks there on the PC runtime, and it already blocks on `main` when the wait started while the call was pending. This PR changes only the "arrives after completion" row, to what the PC runtime does. ### The change - `AState` gets a `signaled` flag, raised after the completion callback (or at completion when there is none, or when the queue is invalid). `get_status(wait)` waits for it. - A call without a result leaves the state table at completion, under the status lock, in the same critical section as the status and the block marker. A waiter that sees a final status therefore finds either no state (returns at once) or the signal. - The table entry is removed only if it is still this call's (`Arc::ptr_eq`). Before, the removal ran after the callback, so a callback that began a new call on the same block lost the new state. - `complete()` reads the callback pointer inside the same critical section and does not touch the block afterwards. Cost: one atomic load per `get_status(wait)`, one extra short lock per completion. No change on the non-waiting path. ### Tests `tests/gdk_xasync_wait.rs`, six cases through the interface slots: | test | main `ad24144` | this PR | |---|---|---| | `wait_on_a_completed_call_with_a_result_returns_after_the_callback` | fails every run | passes | | `block_is_not_written_after_wait_returns` | fails every run | passes | | `wait_on_a_completed_call_without_a_result_does_not_wait_for_the_callback` | passes | passes | | `wait_started_while_pending_returns_after_the_callback` | passes | passes | | `wait_does_not_pump_a_manual_completion_queue` | fails every run (the "after completion" half) | passes | | `wait_on_a_completed_call_without_a_result_leaves_the_callback_queued` | passes | passes | `cargo test -p compat-common --release --no-fail-fast` on `ad24144` plus the first commit: 233 passed, 1 failed, 11 ignored. After the second commit (tests only) I reran the test file alone: 6 passed, 5 runs out of 5. The failure is `gdk_multi_dll`, which did not get as far as running: its nested `cargo build` drops every `TOMBOX_*` variable, this machine has no Windows SDK DXC outside `TOMBOX_DXC_DIR`, and `shaders/query_accum.dxil` is not in the tree, so the `d3d12_xs` build script stops. Not related to this change. With the two-line fix of #212 on top, `gdk_multi_dll` passes here with this PR's `rt.rs` (1 passed). Also run with the conformance scenarios of the old #48 on top (not in this PR, I will resubmit them separately as you asked): the default set passes 8 times out of 8, and `verify_wait_for_completion`, run alone 20 times, goes from 16 / 20 to 20 / 20. ### Not in this PR Measured in passing, left alone because it is a different topic and it changes what a provider must do: after `XAsyncCancel`, the PC runtime leaves the call pending until the provider completes it (status `E_PENDING` right after a cancel that the provider ignores, then the provider's own result). `rt.rs` completes the call itself with `E_ABORT`. That is why `verify_cancellation` and the two `verify_cleanup_waits_for_work` scenarios still differ. No comment lines added (PR gate: 2 files checked, 0 problems). - [x] `cargo test -p compat-common --release`: 233 passed; `gdk_multi_dll` could not build on this machine (see above) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two differences from xgameruntime.dll, found while measuring what a
failed Begin op does.

1. Cleanup of a call completed while its Begin op runs.
   When the call has a completion callback and is completed during the
   Begin op (Begin returns a failure, or XAsyncComplete is called before
   Begin returns, from the same thread or from another one), the PC
   runtime calls the Cleanup op after the completion callback, in the
   dispatch of the completion port. We called Cleanup at once, before
   the callback.
   Unchanged, and the same on the PC runtime: without a completion
   callback Cleanup runs at once; a call completed from DoWork is
   cleaned up at once; a call completed with a payload is not cleaned
   up while its result has not been fetched.

2. XAsyncSchedule on a completed call.
   The PC runtime returns the failure of the call when the call failed,
   and E_INVALIDARG when it succeeded without a payload. It queues
   nothing. We returned E_INVALIDARG for a failed call once its callback
   had run, and S_OK before the callback had run.
   Unchanged, and the same on the PC runtime: a call completed with a
   payload that has not been fetched can be scheduled again.
   XAsyncSchedule(null) now returns E_INVALIDARG before the block is
   read.

Scenarios, expected values measured on xgameruntime.dll 10.0.26100.9656
(gdk_xtaskqueue_conformance_real) before the change:

- verify_failed_begin_reports_its_failure: XAsyncBegin returns S_OK,
  XAsyncGetStatus and XAsyncGetResultSize return the Begin failure as
  soon as XAsyncBegin has returned, no work is queued, the completion
  callback is queued on the completion port and reads the same status,
  XAsyncSchedule returns the failure before and after the callback, the
  provider saw Begin once and Cleanup once.
- verify_cleanup_waits_for_the_callback_when_begin_completes: 18 cases
  (completed by the Begin result, inside Begin, from another thread
  during Begin, in DoWork, in DoWork with a payload; failure or success;
  with or without a completion callback). Each checks how many Cleanup
  ops ran before the completion port was dispatched, how many the
  completion callback saw, how many ran after it, and what
  XAsyncSchedule returns and queues on the completed call.

Both failed on our runtime before the change: the first on the
XAsyncSchedule code, the second on the Cleanup count before dispatch.

A Begin op returning E_PENDING is already covered by
verify_pending_begin_stays_pending (r32j), nothing added for it.

Source: measured behaviour of the PC xgameruntime.dll. No third-party
code.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
get_status(wait) looped on the status, which complete() sets before the
completion callback is queued. A waiter that arrived after XAsyncComplete
of a call with a result returned while the callback was still running.
complete() also wrote the block (mark) after the status was visible, so a
waiter could return and then see the block change under it.

Measured on the PC xgameruntime.dll (thread-pool queue, 12 runs per case):
- call with a result, waiter arrives after completion: returns after the
  completion callback has returned;
- call without a result (size 0 or a failure), waiter arrives after
  completion: returns at once, before the callback;
- waiter started while the call was pending: returns after the callback,
  with or without a result;
- completion while Cleanup is still running: the block does not change
  after the wait has returned.

The state now carries a signal that is raised after the completion
callback (or at completion when there is none). A call without a result
leaves the state table at completion, under the status lock, together
with the block marker. The table entry is only removed if it is still
this call's, so a callback that begins a new call on the same block keeps
the new state.

Tests: tests/gdk_xasync_wait.rs, four cases. Two of them fail on the
previous rt.rs on every run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Measured on the PC xgameruntime.dll (5 runs per case): with a manual
completion port that nobody dispatches, a wait on a call with a result
does not return and does not run the callback itself, whether the waiter
started while the call was pending or after it completed. It returns as
soon as another thread dispatches the port. A completed call without a
result returns at once and leaves its callback queued.

Two tests for these cases. The "after it completed" half fails on the
previous rt.rs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:14:02 +00:00
github-bot closed this pull request 2026-11-26 06:14:02 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 02:10 UTC · original

Thanks, very thorough measurements. Gate clean, and compat-common passes here, including the new gdk_xasync_wait test. It's waiting on a go/no-go from the graphics lead, because it changes XAsync timing for every title and we're in the middle of a Trackmania hang investigation. One question: your measurements use a thread-pool queue. Do you know how the PC runtime behaves when the completion callback goes to a manual-dispatch queue that the waiting thread itself pumps? With this change, that case would block in XAsyncGetStatus(wait). A row for it (measured, or from the AsyncLib design) would help the review.

**@⁠omonkeyz** on GitHub · 2026-11-23 02:10 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7089725377) Thanks, very thorough measurements. Gate clean, and compat-common passes here, including the new gdk_xasync_wait test. It's waiting on a go/no-go from the graphics lead, because it changes XAsync timing for every title and we're in the middle of a Trackmania hang investigation. One question: your measurements use a thread-pool queue. Do you know how the PC runtime behaves when the completion callback goes to a manual-dispatch queue that the waiting thread itself pumps? With this change, that case would block in XAsyncGetStatus(wait). A row for it (measured, or from the AsyncLib design) would help the review.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 02:11 UTC · original

Update from the graphics lead: this is on hold until after the next release is cut. It then gets a Trackmania A/B run. One measurement is needed before it can merge: on the PC runtime, call XAsyncGetStatus(wait = true) on the thread that pumps the call's manual-dispatch completion queue. Use a call that has a result, and complete it from another thread. If the PC runtime deadlocks there too, staying faithful is fine. If it returns, this PR must not introduce that deadlock, for example by dispatching or skipping the pending callback for the waiting thread. Please add that case to your table and to tests/gdk_xasync_wait.rs.

**@⁠omonkeyz** on GitHub · 2026-11-23 02:11 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7089740131) Update from the graphics lead: this is on hold until after the next release is cut. It then gets a Trackmania A/B run. One measurement is needed before it can merge: on the PC runtime, call XAsyncGetStatus(wait = true) on the thread that pumps the call's manual-dispatch completion queue. Use a call that has a result, and complete it from another thread. If the PC runtime deadlocks there too, staying faithful is fine. If it returns, this PR must not introduce that deadlock, for example by dispatching or skipping the pending callback for the waiting thread. Please add that case to your table and to tests/gdk_xasync_wait.rs.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 02:15 UTC · original

One more effect, found while rechecking the conformance scenarios for #211: on ad24144, verify_get_async_status_no_deadlock does not finish (5 runs out of 5, 40 s timeout). It reruns XAsyncRun on the same block as soon as the status is final, 300 times, with no callback. The old removal in complete() ran after the status was visible and was not checked against the state, so it could remove the state of the next call on that block; the scheduled work then finds no state and the block stays E_PENDING. With this PR's Arc::ptr_eq check it passes 10 runs out of 10. The scenario passes on the PC runtime.

With this rt.rs, three DIFFERS entries of #211 pass: that one, verify_wait_for_completion and verify_no_write_after_get_status_race.

**@⁠QuentinDanblon** on GitHub · 2026-11-23 02:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7089797887) One more effect, found while rechecking the conformance scenarios for #211: on `ad24144`, `verify_get_async_status_no_deadlock` does not finish (5 runs out of 5, 40 s timeout). It reruns `XAsyncRun` on the same block as soon as the status is final, 300 times, with no callback. The old removal in `complete()` ran after the status was visible and was not checked against the state, so it could remove the state of the next call on that block; the scheduled work then finds no state and the block stays `E_PENDING`. With this PR's `Arc::ptr_eq` check it passes 10 runs out of 10. The scenario passes on the PC runtime. With this `rt.rs`, three `DIFFERS` entries of #211 pass: that one, `verify_wait_for_completion` and `verify_no_write_after_get_status_race`.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 02:21 UTC · original

Measured, and understood for the hold until after the release.

PC xgameruntime.dll 10.0.26100.9656, queue with a thread-pool work port and a manual completion port that nobody dispatches, the wait on its own thread with a 1.5 s watchdog, then the test thread dispatches the port. 5 runs per case:

case PC runtime main ad24144 this PR
result of 4 bytes, completed from another thread 80 ms after the wait started (your case) does not return; returns once another thread dispatches the port; the callback never ran on the waiting thread same same
result of 4 bytes, wait starts after completion does not return until dispatched returns at once does not return until dispatched
no result, wait starts while pending does not return until dispatched same same
no result, wait starts after completion returns at once, callback left queued same same

So the PC runtime deadlocks there too: the wait never dispatches, and a thread that is the only pump of the completion port and waits on a call with a result stays blocked. For your exact case (completed from another thread while the wait is in progress) main already blocks today, so this PR does not introduce it. The only row this PR changes is the second one.

Added to the table in the description and to tests/gdk_xasync_wait.rs (0908466, tests only): wait_does_not_pump_a_manual_completion_queue covers both halves with a result, and wait_on_a_completed_call_without_a_result_leaves_the_callback_queued the last row. On main the first one fails on its "after completion" half; with this PR the file passes 6 / 6, 5 runs out of 5.

For the Trackmania investigation, in case it helps: on main, a wait that starts while a call is pending already needs the completion port to be dispatched by another thread, whatever the result size. If the title waits on the thread that pumps a manual completion port, that blocks with or without this PR.

**@⁠QuentinDanblon** on GitHub · 2026-11-23 02:21 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7089869773) Measured, and understood for the hold until after the release. PC `xgameruntime.dll` 10.0.26100.9656, queue with a thread-pool work port and a **manual** completion port that nobody dispatches, the wait on its own thread with a 1.5 s watchdog, then the test thread dispatches the port. 5 runs per case: | case | PC runtime | main `ad24144` | this PR | |---|---|---|---| | result of 4 bytes, completed from another thread 80 ms after the wait started (your case) | does not return; returns once another thread dispatches the port; the callback never ran on the waiting thread | same | same | | result of 4 bytes, wait starts after completion | does not return until dispatched | returns at once | does not return until dispatched | | no result, wait starts while pending | does not return until dispatched | same | same | | no result, wait starts after completion | returns at once, callback left queued | same | same | So the PC runtime deadlocks there too: the wait never dispatches, and a thread that is the only pump of the completion port and waits on a call with a result stays blocked. For your exact case (completed from another thread while the wait is in progress) `main` already blocks today, so this PR does not introduce it. The only row this PR changes is the second one. Added to the table in the description and to `tests/gdk_xasync_wait.rs` (`0908466`, tests only): `wait_does_not_pump_a_manual_completion_queue` covers both halves with a result, and `wait_on_a_completed_call_without_a_result_leaves_the_callback_queued` the last row. On `main` the first one fails on its "after completion" half; with this PR the file passes 6 / 6, 5 runs out of 5. For the Trackmania investigation, in case it helps: on `main`, a wait that starts while a call is pending already needs the completion port to be dispatched by another thread, whatever the result size. If the title waits on the thread that pumps a manual completion port, that blocks with or without this PR.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 02:22 UTC · original

Thanks, that answers it. The PC runtime also blocks when the waiting thread is the only pump of the manual completion port, so the faithful behaviour is fine, and the new tests cover it. The fix to the state removal (Arc::ptr_eq) for verify_get_async_status_no_deadlock is noted too. This stays on hold only for the Trackmania A/B, which runs now that the release is cut.

**@⁠omonkeyz** on GitHub · 2026-11-23 02:22 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7089893082) Thanks, that answers it. The PC runtime also blocks when the waiting thread is the only pump of the manual completion port, so the faithful behaviour is fine, and the new tests cover it. The fix to the state removal (Arc::ptr_eq) for verify_get_async_status_no_deadlock is noted too. This stays on hold only for the Trackmania A/B, which runs now that the release is cut.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 10:51 UTC · original

Rebased onto de1e1da (r32j), the branch conflicted with it. Same two commits, now a81ff11 and cb189a9. Nothing else changed.

The conflict was one block in rt.rs: r32j split complete into complete and complete_state, and this PR rewrites the body of that function. I kept the split of r32j with the body of this PR.

On cb189a9, RTX 5090 PC, Windows 11:

  • cargo test -p compat-common --release --test gdk_xasync_wait: 3 runs, 6 passed each.
  • --test gdk_xtaskqueue_conformance: 3 runs, 61 passed each.
  • --test gdk_xtaskqueue_conformance_real (PC xgameruntime.dll 10.0.26100.9656): 61 passed.
  • --lib: 3 runs, 147 passed each.
  • pr_gate.py --base origin/main: 0 problems.

Not run here: cargo check --workspace stops on this PC at the build scripts of connectedstorageservice_proxystub and gamecorecomproxy (their local data/*.bin inputs are missing). CI covers it.

If your Trackmania A/B was done on the old head 0908466, the change is the same, applied to the function that r32j named complete_state.

This PR and #271 change the same function (complete_state), so they conflict with each other (git merge-tree). #270 does not conflict with this one. I will rebase whichever of #210 and #271 is merged second.

**@⁠QuentinDanblon** on GitHub · 2026-11-23 10:51 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7098601544) Rebased onto `de1e1da` (r32j), the branch conflicted with it. Same two commits, now `a81ff11` and `cb189a9`. Nothing else changed. The conflict was one block in `rt.rs`: r32j split `complete` into `complete` and `complete_state`, and this PR rewrites the body of that function. I kept the split of r32j with the body of this PR. On `cb189a9`, RTX 5090 PC, Windows 11: - `cargo test -p compat-common --release --test gdk_xasync_wait`: 3 runs, 6 passed each. - `--test gdk_xtaskqueue_conformance`: 3 runs, 61 passed each. - `--test gdk_xtaskqueue_conformance_real` (PC `xgameruntime.dll` 10.0.26100.9656): 61 passed. - `--lib`: 3 runs, 147 passed each. - `pr_gate.py --base origin/main`: 0 problems. Not run here: `cargo check --workspace` stops on this PC at the build scripts of `connectedstorageservice_proxystub` and `gamecorecomproxy` (their local `data/*.bin` inputs are missing). CI covers it. If your Trackmania A/B was done on the old head `0908466`, the change is the same, applied to the function that r32j named `complete_state`. This PR and #271 change the same function (`complete_state`), so they conflict with each other (`git merge-tree`). #270 does not conflict with this one. I will rebase whichever of #210 and #271 is merged second.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 10:54 UTC · original

Thanks for the rebase. We're bundling this with #270 and #271 for one full-boot Trackmania gate in the next release. On top of those two, a81ff11 conflicts in crates/compat/compat-common/src/gdk/rt.rs, because #271 changes the same completion path. Could you rebase this branch onto #271's head, so the three stack in order (#270, #271, #210)? Then please run the gdk_xasync_wait and conformance tests again on that stack. I'd rather not resolve a conflict in the completion logic myself.

**@⁠omonkeyz** on GitHub · 2026-11-23 10:54 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7098696151) Thanks for the rebase. We're bundling this with #270 and #271 for one full-boot Trackmania gate in the next release. On top of those two, a81ff11 conflicts in crates/compat/compat-common/src/gdk/rt.rs, because #271 changes the same completion path. Could you rebase this branch onto #271's head, so the three stack in order (#270, #271, #210)? Then please run the gdk_xasync_wait and conformance tests again on that stack. I'd rather not resolve a conflict in the completion logic myself.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 11:04 UTC · original

Done. This branch now sits on #271's head (4299f39): #271's commit, then 0611df3 and 9ebd0e2 (the same two changes as before). #270 is not in the branch; it merges on top without conflict.

The conflict was in complete_state, three blocks. Resolution, so you can check it without redoing it:

  • This PR's part is kept as is: the status, mark and the removal from the state map (with Arc::ptr_eq) happen under the status lock, and the end of the call is signal() (sets signaled, then notify_all) instead of cv.notify_all().
  • #271's part is kept as is: after_callback = !keep && callback.is_some() && in_begin; Cleanup runs at once only when !keep && !after_callback; otherwise it runs in the completion job after the callback, or in the Queued::Invalid arm.
  • In the completion job, the order is: callback, then Cleanup if after_callback, then signal(). So a XAsyncGetStatus(wait = true) that returns has seen the Cleanup of a call completed during Begin.

Tests, RTX 5090 PC, Windows 11, release:

Stack #270 + #271 + #210 (this branch with #270's head merged in, local only):

  • --test gdk_xasync_wait: 3 runs, 6 passed each.
  • --test gdk_xtaskqueue_conformance: 3 runs, 64 passed each.
  • --test gdk_xtaskqueue_conformance_real (PC xgameruntime.dll 10.0.26100.9656): 64 passed.
  • --lib: 3 runs, 149 passed each.

This branch alone (#271 + #210):

  • gdk_xasync_wait 6 passed, gdk_xtaskqueue_conformance 63 passed, gdk_xtaskqueue_conformance_real 63 passed, --lib 147 passed.
  • pr_gate.py --base origin/main: 0 problems.

The stack was tested on de1e1da. main has since moved to r32k (2d4cbd5); git merge-tree shows no conflict between it and each of #270, #271 and this branch. I did not rerun the tests on r32k.

Once #271 is merged, this PR's diff shows only its two commits.

**@⁠QuentinDanblon** on GitHub · 2026-11-23 11:04 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7099003346) Done. This branch now sits on #271's head (`4299f39`): #271's commit, then `0611df3` and `9ebd0e2` (the same two changes as before). #270 is not in the branch; it merges on top without conflict. The conflict was in `complete_state`, three blocks. Resolution, so you can check it without redoing it: - This PR's part is kept as is: the status, `mark` and the removal from the state map (with `Arc::ptr_eq`) happen under the status lock, and the end of the call is `signal()` (sets `signaled`, then `notify_all`) instead of `cv.notify_all()`. - #271's part is kept as is: `after_callback = !keep && callback.is_some() && in_begin`; Cleanup runs at once only when `!keep && !after_callback`; otherwise it runs in the completion job after the callback, or in the `Queued::Invalid` arm. - In the completion job, the order is: callback, then Cleanup if `after_callback`, then `signal()`. So a `XAsyncGetStatus(wait = true)` that returns has seen the Cleanup of a call completed during Begin. Tests, RTX 5090 PC, Windows 11, release: **Stack #270 + #271 + #210** (this branch with #270's head merged in, local only): - `--test gdk_xasync_wait`: 3 runs, 6 passed each. - `--test gdk_xtaskqueue_conformance`: 3 runs, 64 passed each. - `--test gdk_xtaskqueue_conformance_real` (PC `xgameruntime.dll` 10.0.26100.9656): 64 passed. - `--lib`: 3 runs, 149 passed each. **This branch alone** (#271 + #210): - `gdk_xasync_wait` 6 passed, `gdk_xtaskqueue_conformance` 63 passed, `gdk_xtaskqueue_conformance_real` 63 passed, `--lib` 147 passed. - `pr_gate.py --base origin/main`: 0 problems. The stack was tested on `de1e1da`. `main` has since moved to r32k (`2d4cbd5`); `git merge-tree` shows no conflict between it and each of #270, #271 and this branch. I did not rerun the tests on r32k. Once #271 is merged, this PR's diff shows only its two commits.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 13:45 UTC · original

Applied locally on main with your authorship kept (cherry-picked, 139f94c); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.

**@⁠omonkeyz** on GitHub · 2026-11-23 13:45 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7102983894) Applied locally on main with your authorship kept (cherry-picked, 139f94c); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.
Author
Owner

@⁠kiwe147 on GitHub · 2026-11-23 19:15 UTC · original

Tested head 9ebd0e2adb, applied with git apply (whitespace ignored, the line endings of my checkout differ) on main f89e410, together with #227 (one tree; the PRs touch different files). It applied without conflicts and built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1.

run result
cargo test -p compat-common 391 passed, 1 failed (the same 1 fail on main: history_frames_are_compressed_and_clips_are_h264 returns 0x8007007F on this machine)

No new failure against main f89e410 in any of these. This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

**@⁠kiwe147** on GitHub · 2026-11-23 19:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7111316206) Tested head `9ebd0e2adb`, applied with `git apply` (whitespace ignored, the line endings of my checkout differ) on `main` `f89e410`, together with #227 (one tree; the PRs touch different files). It applied without conflicts and built. Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1. | run | result | |---|---| | `cargo test -p compat-common` | 391 passed, 1 failed (the same 1 fail on `main`: `history_frames_are_compressed_and_clips_are_h264` returns 0x8007007F on this machine) | No new failure against `main` `f89e410` in any of these. This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code)
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:09 UTC · original

Applied on main in 139f94c (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:09 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/210#issuecomment-7163372913) Applied on main in 139f94c (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.