HLE: deliver initial XNetworking registration callbacks and track unregister tokens #2998

Open
github-bot wants to merge 1 commit from github-bot/gh-2998 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 02:58 UTC · original
fuzeofficlal:fix/hle-xnetworking-initial-callbacks → main · +317 −53 · 3 files · 1 commits · open

Summary

  • Deliver the initial XNetworking registration callbacks through the caller's XTaskQueue completion port (XTaskQueueSubmitDelayedCallback with zero delay) for both preferred local UDP multiplayer port (0x30, 3074) and connectivity hint (0x80, OFFLINE with initialized = true).
  • Track active registration tokens in xnetworking.rs so 0x38 (unregister_port) and 0x88 (unregister_hint) only cancel and remove matching event registrations, prevent double-unregistration, honor wait = true via condvar synchronization when a callback is currently executing on another thread, and avoid self-deadlock when a callback attempts to unregister itself.
  • Return E_INVALIDARG when either the callback pointer (_In_) or output token pointer (_Out_) is null, and roll back the registration + output token if task-queue submission fails.

Specification basis (public Microsoft Learn GDK documentation)

Verification

  • Synthetic unit tests only (no title run performed here).
  • cargo test -p victory-hle --locked modules::xnetworking:: and modules::xasync::: all tests passed (including 4 new unit tests covering completion-port delivery, token/event matching and cancellation, null callback/token rejection, and immediate-queue self-unregister safety).
  • cargo clippy -p victory-hle --locked --all-targets -- -D warnings (default and --all-features): 0 warnings.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: ok.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2998) `fuzeofficlal:fix/hle-xnetworking-initial-callbacks` → `main` · +317 −53 · 3 files · 1 commits · open ## Summary - Deliver the initial `XNetworking` registration callbacks through the caller's `XTaskQueue` completion port (`XTaskQueueSubmitDelayedCallback` with zero delay) for both preferred local UDP multiplayer port (`0x30`, `3074`) and connectivity hint (`0x80`, `OFFLINE` with `initialized = true`). - Track active registration tokens in `xnetworking.rs` so `0x38` (`unregister_port`) and `0x88` (`unregister_hint`) only cancel and remove matching event registrations, prevent double-unregistration, honor `wait = true` via condvar synchronization when a callback is currently executing on another thread, and avoid self-deadlock when a callback attempts to unregister itself. - Return `E_INVALIDARG` when either the callback pointer (`_In_`) or output token pointer (`_Out_`) is null, and roll back the registration + output token if task-queue submission fails. ## Specification basis (public Microsoft Learn GDK documentation) - [`XNetworkingRegisterConnectivityHintChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingregisterconnectivityhintchanged) — Remarks: *"This function registers a 'connectivity hint changed' notification and sends an initial notification callback."* `queue` and `context` are `_In_opt_` (a null queue uses the process task queue, matching `xasync::queue`), while `callback` (`_In_`) and `token` (`_Out_`) are required. See also [Detecting network initialization status](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/console/networking/initialization-connectivity-networking) (titles can wait for `XNetworkingConnectivityHint::networkInitialized == true` via `XNetworkingRegisterConnectivityHintChanged`). - [`XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingregisterpreferredlocaludpmultiplayerportchanged) — Remarks: *"Registering for a preferred local User Datagram Protocol (UDP) multiplayer port change notification always fires an initial notification callback."* `queue` and `context` are `_In_opt_` (using the queue's completion port for callback delivery), while `callback` (`_In_`) and `token` (`_Out_`) are required. See also [Preferred local UDP multiplayer port networking APIs](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/console/networking/game-mesh/preferred-local-udp-multiplayer-port-networking) (lists notification registration as one of the three ways to retrieve the initial preferred port). - [`XNetworkingUnregisterConnectivityHintChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingunregisterconnectivityhintchanged) and [`XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingunregisterpreferredlocaludpmultiplayerportchanged) — document the `wait` blocking behavior and polling (`wait == false` returns `false` while a callback is executing and `true` once completed). ## Verification - Synthetic unit tests only (no title run performed here). - `cargo test -p victory-hle --locked modules::xnetworking::` and `modules::xasync::`: all tests passed (including 4 new unit tests covering completion-port delivery, token/event matching and cancellation, null callback/token rejection, and immediate-queue self-unregister safety). - `cargo clippy -p victory-hle --locked --all-targets -- -D warnings` (default and `--all-features`): 0 warnings. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: ok.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:44 +00:00
github-bot force-pushed github-bot/gh-2998 from a60d2794e7 to ede11f17fb 2026-11-26 06:30:29 +00:00 Compare
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 04:44 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head a60d279 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 870 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: initial_callbacks_use_the_completion_port, unregister_cancels_only_the_matching_token, registration_rejects_missing_callback_or_token, immediate_callback_can_try_to_unregister_itself.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 04:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2998#issuecomment-7182862703) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `a60d279` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **870 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `initial_callbacks_use_the_completion_port`, `unregister_cancels_only_the_matching_token`, `registration_rejects_missing_callback_or_token`, `immediate_callback_can_try_to_unregister_itself`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:23 UTC · original · edited 2026-11-26 07:19 UTC

Automated triage for the maintainers.

Thanks for the references; they answer our request for evidence. The public documentation for both registration functions says an initial notification is always sent, and that callback and token are required. The new code in crates/victory-hle/src/modules/xnetworking.rs matches this. register queues deliver_initial on the caller's queue (completion port) with zero delay and returns E_INVALIDARG for a null callback or token. unregister matches the token and the event, drops a callback that is still pending, and waits for a running one unless that callback is unregistering itself. The answers stay OFFLINE and port 3074, so nothing new reaches the network. The VTABLE alignment nit is fixed.

Merge candidate. One point for the maintainers: there is no title run, so any effect on the title's startup ordering is unmeasured.

CI: passing.

Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 05:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2998#issuecomment-7183449835) · edited 2026-11-26 07:19 UTC <!-- victory-triage v1 head=ede11f17fb3b755075bf225eefcfdfe5de323d4e verdict=merge-candidate at=2026-11-26T07:19:40Z --> Automated triage for the maintainers. Thanks for the references; they answer our request for evidence. The public documentation for both registration functions says an initial notification is always sent, and that `callback` and `token` are required. The new code in `crates/victory-hle/src/modules/xnetworking.rs` matches this. `register` queues `deliver_initial` on the caller's queue (completion port) with zero delay and returns `E_INVALIDARG` for a null callback or token. `unregister` matches the token and the event, drops a callback that is still pending, and waits for a running one unless that callback is unregistering itself. The answers stay `OFFLINE` and port 3074, so nothing new reaches the network. The `VTABLE` alignment nit is fixed. **Merge candidate.** One point for the maintainers: there is no title run, so any effect on the title's startup ordering is unmeasured. CI: passing. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 05:40 UTC · original

Updated the PR description with the public Microsoft Learn GDK references and fixed the VTABLE comment column alignment nit on rows 0x30, 0x38, 0x80, and 0x88:

Not tested with a title run (unit tests + public API spec only). Re-verified cargo test -p victory-hle --locked modules::xnetworking:: (5/5), cargo clippy -p victory-hle --locked --all-targets -- -D warnings, and policy::tests::repository_passes_policy after the nit fix.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 05:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2998#issuecomment-7183700039) Updated the PR description with the public Microsoft Learn GDK references and fixed the `VTABLE` comment column alignment nit on rows `0x30`, `0x38`, `0x80`, and `0x88`: - [`XNetworkingRegisterConnectivityHintChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingregisterconnectivityhintchanged) explicitly documents: *"This function registers a 'connectivity hint changed' notification and sends an initial notification callback."* (`callback` is `_In_`, `token` is `_Out_`; `queue` and `context` are `_In_opt_`). - [`XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingregisterpreferredlocaludpmultiplayerportchanged) explicitly documents: *"Registering for a preferred local User Datagram Protocol (UDP) multiplayer port change notification always fires an initial notification callback."* (`callback` is `_In_`, `token` is `_Out_`; `queue` and `context` are `_In_opt_`). - [`XNetworkingUnregisterConnectivityHintChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingunregisterconnectivityhintchanged) / [`XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/networking/xnetworking/functions/xnetworkingunregisterpreferredlocaludpmultiplayerportchanged) document the `wait` blocking / non-blocking poll return semantics. Not tested with a title run (unit tests + public API spec only). Re-verified `cargo test -p victory-hle --locked modules::xnetworking::` (5/5), `cargo clippy -p victory-hle --locked --all-targets -- -D warnings`, and `policy::tests::repository_passes_policy` after the nit fix.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2998/head:github-bot/gh-2998'
git switch 'github-bot/gh-2998'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2998'
git switch 'github-bot/gh-2998'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2998'
git switch 'github-bot/gh-2998'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2998'
git switch 'main'
git merge --squash 'github-bot/gh-2998'
git switch 'main'
git merge --ff-only 'github-bot/gh-2998'
git switch 'main'
git merge 'github-bot/gh-2998'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2998
No description provided.