HLE: deliver initial XNetworking registration callbacks and track unregister tokens #2996
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2998"
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 Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:58:32Z.
Summary
XNetworkingregistration callbacks through the caller'sXTaskQueuecompletion port (XTaskQueueSubmitDelayedCallbackwith zero delay) for both preferred local UDP multiplayer port (0x30,3074) and connectivity hint (0x80,OFFLINEwithinitialized = true).xnetworking.rsso0x38(unregister_port) and0x88(unregister_hint) only cancel and remove matching event registrations, prevent double-unregistration, honorwait = truevia condvar synchronization when a callback is currently executing on another thread, and avoid self-deadlock when a callback attempts to unregister itself.E_INVALIDARGwhen 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— Remarks: "This function registers a 'connectivity hint changed' notification and sends an initial notification callback."queueandcontextare_In_opt_(a null queue uses the process task queue, matchingxasync::queue), whilecallback(_In_) andtoken(_Out_) are required. See also Detecting network initialization status (titles can wait forXNetworkingConnectivityHint::networkInitialized == trueviaXNetworkingRegisterConnectivityHintChanged).XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged— Remarks: "Registering for a preferred local User Datagram Protocol (UDP) multiplayer port change notification always fires an initial notification callback."queueandcontextare_In_opt_(using the queue's completion port for callback delivery), whilecallback(_In_) andtoken(_Out_) are required. See also Preferred local UDP multiplayer port networking APIs (lists notification registration as one of the three ways to retrieve the initial preferred port).XNetworkingUnregisterConnectivityHintChangedandXNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged— document thewaitblocking behavior and polling (wait == falsereturnsfalsewhile a callback is executing andtrueonce completed).Verification
cargo test -p victory-hle --locked modules::xnetworking::andmodules::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.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T03:05:04Z.
Review: APPROVED
LGTM — verified the delivery state machine. Running(tid) is set under the lock before invoking, so unregister(wait=true) blocks on RETURNED until the callback returns and no path can remove the entry mid-callback (the get_mut unwrap is safe). put(out, id) precedes submit since an immediate queue can fire inside it — the queue(3) self-unregister test proves that path returns false. Cross-event unregister is filtered by r.event, pending-cancel discards cleanly, failure path removes + zeroes the token. Tests discriminate all four states.
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T04:44:35Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
a60d279(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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.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.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:23:56Z.
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
callbackandtokenare required. The new code incrates/victory-hle/src/modules/xnetworking.rsmatches this.registerqueuesdeliver_initialon the caller's queue (completion port) with zero delay and returnsE_INVALIDARGfor a null callback or token.unregistermatches 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 stayOFFLINEand port 3074, so nothing new reaches the network. TheVTABLEalignment 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
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:40:23Z.
Updated the PR description with the public Microsoft Learn GDK references and fixed the
VTABLEcomment column alignment nit on rows0x30,0x38,0x80, and0x88:XNetworkingRegisterConnectivityHintChangedexplicitly documents: "This function registers a 'connectivity hint changed' notification and sends an initial notification callback." (callbackis_In_,tokenis_Out_;queueandcontextare_In_opt_).XNetworkingRegisterPreferredLocalUdpMultiplayerPortChangedexplicitly documents: "Registering for a preferred local User Datagram Protocol (UDP) multiplayer port change notification always fires an initial notification callback." (callbackis_In_,tokenis_Out_;queueandcontextare_In_opt_).XNetworkingUnregisterConnectivityHintChanged/XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChangeddocument thewaitblocking / 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, andpolicy::tests::repository_passes_policyafter the nit fix.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:31:37Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-hle xnetworking: all tests passed.cargo test -p victory-hle xasync: all tests passed.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.