Skip to content

XGameRuntime: XNetworking change registrations fire the initial callback - #1237

Open
emirduran707 wants to merge 1 commit into
xcl-dev:mainfrom
emirduran707:xnetworking-initial-callbacks
Open

emirduran707 wants to merge 1 commit into
xcl-dev:mainfrom
emirduran707:xnetworking-initial-callbacks

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

XNetworkingRegisterConnectivityHintChanged and XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged handed out a token and never called the callback. Microsoft's documentation says both send a first callback when they register: the connectivity one "registers a "connectivity hint changed" notification and sends an initial notification callback", and the port one "always fires an initial notification callback". The network-initialization guidance builds on that: a title registers and then waits for the callback to report networkInitialized. Under XCL such a title waited forever, or treated the network as not up.

Both now write the token, then queue one callback on the queue's completion port through xasync::submit_callback, as notify_association does for user-association changes. The connectivity callback carries the current hint from XNetworkingGetConnectivityHint, and the port callback carries DEFAULT_UDP_PORT. A null callback is E_INVALIDARG, as for XUserRegisterForDeviceAssociationChanged. If the queue refuses the callback, its record is freed and a warning is logged.

What is in it

  • crates/xcl/src/hle/xgameruntime/networking.rs: the first callbacks; test register_fires_an_initial_callback. It uses an immediate queue and checks that each callback runs once, with network_initialized true and port 3074, and that a null callback is refused.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on e2a4b1d: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test without the change in the two register functions: callback count left: 0, right: 1; with it it passes

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: e2a4b1d3190260b7a8799b916b5de5f7a5b69ab1
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1481 (PresentX 1481)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19710 MB

Not tested

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

XNetworkingRegisterConnectivityHintChanged and
XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged only handed out
a token and never called the title's callback. The GDK docs say the first
"registers a "connectivity hint changed" notification and sends an initial
notification callback", and that registering for the second "always fires
an initial notification callback". A title that waits for that callback
(for instance to see networkInitialized) waited forever.

Both now queue one callback on the queue's completion port, as
XUserRegisterForDeviceAssociationChanged does: the current hint (from
XNetworkingGetConnectivityHint) or DEFAULT_UDP_PORT. The record is freed
when the queue refuses it, and a canceled callback only frees it. The
callback is `_In_` in both signatures, so a null one is E_INVALIDARG, like
the XUser registration.

register_fires_an_initial_callback fails without this change (callback
count 0 after registering on an Immediate/Immediate queue).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

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

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

Thanks!

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