HLE: serialize device callbacks across delivery threads #613

Closed
Quat3rnion wants to merge 2 commits from upstream-pr/613 into main
Quat3rnion commented 2026-11-24 05:36:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T05:36:12Z.


What

The registration thread and the poll thread both called deliver directly,
so an initial enumeration callback and a hotplug notification could run at
the same time. GameInput guarantees callbacks arrive one at a time in order,
and titles rely on that when maintaining a device list. Events now go through
one queue in the hub's state with a single delivery loop; a callback that
enqueues more events joins the same loop instead of nesting. The existing
running-callback tracking still lets UnregisterCallback wait for a callback
that is in flight.

An AI tool wrote part of this change.

Tested

  • Linux: cargo test --workspace: 165 passed, 0 failed, 3 ignored. A regression holds a blocking enumeration callback open on one thread while another thread connects a fake pad and polls, then checks peak simultaneous callbacks is one and that all notifications were delivered.
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. No Windows host here.
  • cargo xtask policy passes (150 files ok). No game files or data from them were added.

Checklist

  • Workspace tests and Windows cross-check pass.
  • cargo xtask policy passes. No game files or data from them were added.
  • AI authorship is disclosed above.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6575402882 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-24T05:36:12Z. --- ## What The registration thread and the poll thread both called `deliver` directly, so an initial enumeration callback and a hotplug notification could run at the same time. GameInput guarantees callbacks arrive one at a time in order, and titles rely on that when maintaining a device list. Events now go through one queue in the hub's state with a single delivery loop; a callback that enqueues more events joins the same loop instead of nesting. The existing running-callback tracking still lets `UnregisterCallback` wait for a callback that is in flight. An AI tool wrote part of this change. ## Tested - Linux: `cargo test --workspace`: 165 passed, 0 failed, 3 ignored. A regression holds a blocking enumeration callback open on one thread while another thread connects a fake pad and polls, then checks peak simultaneous callbacks is one and that all notifications were delivered. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. No Windows host here. - `cargo xtask policy` passes (150 files ok). No game files or data from them were added. ## Checklist - [x] Workspace tests and Windows cross-check pass. - [x] `cargo xtask policy` passes. No game files or data from them were added. - [x] AI authorship is disclosed above.
LAKSHYA-cmd-tech commented 2026-11-24 06:53:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:01:50Z.

Review: APPROVED


Tested on native Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-hle: all 82 tests in ictory_hle and
    o_dll_planting passed cleanly.
  • callbacks_from_registration_and_poll_are_serialized successfully verified that concurrent enumeration and poll threads serialize device callback delivery with a peak of 1.
  • cargo xtask policy: 150 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034429661 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#pullrequestreview-6034429661). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:01:50Z. **Review:** APPROVED --- Tested on native Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-hle: all 82 tests in ictory_hle and o_dll_planting passed cleanly. - callbacks_from_registration_and_poll_are_serialized successfully verified that concurrent enumeration and poll threads serialize device callback delivery with a peak of 1. - cargo xtask policy: 150 files ok.
dpalacios69 commented 2026-11-24 11:04:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dpalacios69 on 2026-11-24T10:46:10Z.


Nice cleanup on serializing Hub::deliver! One edge case to double-check for GameInputBlockingEnumeration:

In register_device_callback (gameinput.rs:781), hub.deliver(found) is called right before returning S_OK. With the new early return when state.delivering is already true (gameinput.rs:416–445), if the poll thread (or another thread) is currently inside a callback, RegisterDeviceCallback(..., BlockingEnumeration, ...) appends found to state.queue and returns S_OK before the initial enumeration callbacks have actually run.

Per the public GameInput API contract, GameInputBlockingEnumeration guarantees initial callbacks complete synchronously before RegisterDeviceCallback returns. (Waiting on self.returned from a different thread would address that, though it would need care if an in-flight callback can ever synchronize with the registering thread to avoid a deadlock — and same-thread re-entrant registration must still return immediately.)

Worth considering whether BlockingEnumeration should wait for its queued batch to drain (with a regression test covering poll() active during registration), or documenting the behavior if titles don't depend on it here.

Static code review only; AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129219998 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7129219998). Originally posted by [dpalacios69](https://github.com/dpalacios69) on 2026-11-24T10:46:10Z. --- Nice cleanup on serializing `Hub::deliver`! One edge case to double-check for `GameInputBlockingEnumeration`: In `register_device_callback` (`gameinput.rs:781`), `hub.deliver(found)` is called right before returning `S_OK`. With the new early return when `state.delivering` is already `true` (`gameinput.rs:416–445`), if the poll thread (or another thread) is currently inside a callback, `RegisterDeviceCallback(..., BlockingEnumeration, ...)` appends `found` to `state.queue` and returns `S_OK` before the initial enumeration callbacks have actually run. Per the public GameInput API contract, `GameInputBlockingEnumeration` guarantees initial callbacks complete synchronously before `RegisterDeviceCallback` returns. (Waiting on `self.returned` from a different thread would address that, though it would need care if an in-flight callback can ever synchronize with the registering thread to avoid a deadlock — and same-thread re-entrant registration must still return immediately.) Worth considering whether `BlockingEnumeration` should wait for its queued batch to drain (with a regression test covering `poll()` active during registration), or documenting the behavior if titles don't depend on it here. Static code review only; AI-assisted.
geiyiliyabumo commented 2026-11-24 11:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T10:55:29Z.


Independent verification & code review on Windows 11 Pro (build 26100, Rust 1.98.1), cleanly merged onto main (ffe310e):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: PASS
  • cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings: PASS
  • cargo test -p victory-hle --locked: 95 passed + 1 integration test (no_dll_planting), 0 failed (including new callbacks_from_registration_and_poll_are_serialized)

Diff review notes (crates/victory-hle/src/modules/gameinput.rs)

  1. BlockingEnumeration contract race (register_device -> deliver): When register_device is called with BlockingEnumeration (2) from thread B while thread A (e.g. poll) is currently inside a callback (state.delivering == true), deliver(found) appends found to state.queue and returns immediately — so RegisterDeviceCallback returns S_OK before its initial enumeration callbacks have actually run. Tracking delivering: Option<ThreadId> (instead of bool) would let a blocking registration from another thread wait on self.returned until its queued events drain, while still returning without deadlocking if called re-entrantly from the delivering thread.
  2. Minor lock merge (deliver lines 435–452): Popping state.queue.pop_front(), checking state.callbacks, and pushing (r.token, me) to state.running can happen under a single self.state() lock acquisition instead of unlocking and immediately relocking. (Also forget could optionally prune state.queue alongside state.pending, though deliver already skips unregistered tokens safely.)

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129424157 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7129424157). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T10:55:29Z. --- Independent verification & code review on Windows 11 Pro (build 26100, Rust `1.98.1`), cleanly merged onto `main` (`ffe310e`): - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: PASS - `cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings`: PASS - `cargo test -p victory-hle --locked`: **95 passed + 1 integration test (`no_dll_planting`), 0 failed** (including new `callbacks_from_registration_and_poll_are_serialized`) ### Diff review notes (`crates/victory-hle/src/modules/gameinput.rs`) 1. **`BlockingEnumeration` contract race (`register_device` -> `deliver`)**: When `register_device` is called with `BlockingEnumeration` (`2`) from thread B while thread A (e.g. `poll`) is currently inside a callback (`state.delivering == true`), `deliver(found)` appends `found` to `state.queue` and returns immediately — so `RegisterDeviceCallback` returns `S_OK` before its initial enumeration callbacks have actually run. Tracking `delivering: Option<ThreadId>` (instead of `bool`) would let a blocking registration from another thread wait on `self.returned` until its queued events drain, while still returning without deadlocking if called re-entrantly from the delivering thread. 2. **Minor lock merge (`deliver` lines 435–452)**: Popping `state.queue.pop_front()`, checking `state.callbacks`, and pushing `(r.token, me)` to `state.running` can happen under a single `self.state()` lock acquisition instead of unlocking and immediately relocking. (Also `forget` could optionally prune `state.queue` alongside `state.pending`, though `deliver` already skips unregistered tokens safely.) *AI-assisted; synthetic tests only, no game files.*
mercuryVM commented 2026-11-24 12:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:26:20Z.

Review: CHANGES_REQUESTED


Tested 2750ab1 on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 88 passed, including callbacks_from_registration_and_poll_are_serialized.

The single queue does serialize callbacks, but it breaks blocking enumeration in the other ordering:

  • gameinput.rs (register_device, then Hub::deliver): when a blocking-enumeration RegisterDeviceCallback arrives while the poll thread is already inside deliver (delivering == true), the registration's found events are appended to queue and deliver returns at once. register_device then returns S_OK before any of its enumeration callbacks have run, and they run later on the poll thread. The doc comment above register_device promises they run "blocking on the caller's thread before we return". GameInput's blocking enumeration means the title's device list is complete when the call returns, and the title holds the lock its callback needs, so it can't observe the late callbacks until it releases that lock. The new test only covers registration-first-then-poll, not poll-first-then-register.
  • Possible fix: don't make the registration visible to the poll thread until its own enumeration is done. Deliver found synchronously on the caller's thread, then push the registration into state.callbacks and queue any hotplug events that arrived meanwhile. That keeps one-at-a-time delivery per callback and keeps the blocking guarantee. Waiting on a condvar for the queue to drain would deadlock in exactly the lock-holding case the comment describes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038361303 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#pullrequestreview-6038361303). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:26:20Z. **Review:** CHANGES_REQUESTED --- Tested 2750ab1 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` 88 passed, including `callbacks_from_registration_and_poll_are_serialized`. The single queue does serialize callbacks, but it breaks blocking enumeration in the other ordering: - `gameinput.rs` (`register_device`, then `Hub::deliver`): when a blocking-enumeration `RegisterDeviceCallback` arrives while the poll thread is already inside `deliver` (`delivering == true`), the registration's `found` events are appended to `queue` and `deliver` returns at once. `register_device` then returns `S_OK` before any of its enumeration callbacks have run, and they run later on the poll thread. The doc comment above `register_device` promises they run "blocking on the caller's thread before we return". GameInput's blocking enumeration means the title's device list is complete when the call returns, and the title holds the lock its callback needs, so it can't observe the late callbacks until it releases that lock. The new test only covers registration-first-then-poll, not poll-first-then-register. - Possible fix: don't make the registration visible to the poll thread until its own enumeration is done. Deliver `found` synchronously on the caller's thread, then push the registration into `state.callbacks` and queue any hotplug events that arrived meanwhile. That keeps one-at-a-time delivery per callback and keeps the blocking guarantee. Waiting on a condvar for the queue to drain would deadlock in exactly the lock-holding case the comment describes. AI-assisted (Claude Code).
MichaelSmithAI commented 2026-11-24 12:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T11:10:57Z.


We ran a focused test for the blocking-enumeration question above on exact head 2750ab1 with Win64 under Wine. One thread held an existing callback open. A second thread called RegisterDeviceCallback through the GameInput vtable with GameInputBlockingEnumeration. It returned S_OK with zero initial callbacks completed. After the first callback was released, the initial callback ran once.

This gives a regression assertion for the queue change: on the registering thread, read the completed-callback count immediately after the API returns and expect one. The existing serialization test checks the complementary requirement that callbacks do not overlap. GameInput registration contract

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129763766 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7129763766). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T11:10:57Z. --- We ran a focused test for the blocking-enumeration question above on exact head `2750ab1` with Win64 under Wine. One thread held an existing callback open. A second thread called `RegisterDeviceCallback` through the GameInput vtable with `GameInputBlockingEnumeration`. It returned `S_OK` with **zero** initial callbacks completed. After the first callback was released, the initial callback ran once. This gives a regression assertion for the queue change: on the registering thread, read the completed-callback count immediately after the API returns and expect one. The existing serialization test checks the complementary requirement that callbacks do not overlap. [GameInput registration contract](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback)
mercuryVM commented 2026-11-24 15:03:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T14:32:06Z.

Review: APPROVED


Re-tested 7da55be on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 98 passed, including the new regression, where a blocking enumeration callback is held open on one thread while another connects a fake pad and polls. cargo clippy -p victory-hle --all-targets is clean.

This addresses my earlier review:

  • When a blocking registration arrives while another thread is delivering, its own enumeration events run inline on the caller's thread, and the registration sits in enumerating, invisible to the poll thread, until they're done. So RegisterDeviceCallback returns only after its enumeration ran.
  • Hotplug events that arrive in the meantime are held in the Enumeration's hotplug list and queued afterwards, keeping order per callback.
  • When no one is delivering, the caller claims delivery and drains synchronously, which also satisfies the blocking contract.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6041124604 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#pullrequestreview-6041124604). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T14:32:06Z. **Review:** APPROVED --- Re-tested 7da55be on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` 98 passed, including the new regression, where a blocking enumeration callback is held open on one thread while another connects a fake pad and polls. `cargo clippy -p victory-hle --all-targets` is clean. This addresses my earlier review: - When a blocking registration arrives while another thread is delivering, its own enumeration events run inline on the caller's thread, and the registration sits in `enumerating`, invisible to the poll thread, until they're done. So `RegisterDeviceCallback` returns only after its enumeration ran. - Hotplug events that arrive in the meantime are held in the `Enumeration`'s `hotplug` list and queued afterwards, keeping order per callback. - When no one is delivering, the caller claims delivery and drains synchronously, which also satisfies the blocking contract. AI-assisted (Claude Code).
Quat3rnion commented 2026-11-24 15:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T14:13:28Z.


@mercuryVM Blocking enumeration now finishes on the registering thread before returning, even when a poll callback is active. Hotplug events for that registration wait until enumeration finishes. Both cases have regression tests, and cargo test -p victory-hle --no-fail-fast passed all 54 tests on Linux at 7da55bef. Could you re-check?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134031454 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7134031454). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-24T14:13:28Z. --- @mercuryVM Blocking enumeration now finishes on the registering thread before returning, even when a poll callback is active. Hotplug events for that registration wait until enumeration finishes. Both cases have regression tests, and `cargo test -p victory-hle --no-fail-fast` passed all 54 tests on Linux at `7da55bef`. Could you re-check?
ThomasHFWright commented 2026-11-24 16:05:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ThomasHFWright on 2026-11-24T15:08:28Z.


Re-tested the revised callback implementation at 7da55befe68142103d81110c5eaab47a8f4d6b43 under Wine, with this PR's complete diff applied to current main ffe310eb2098e52169f4c44db5ffdabf43a72622 in an isolated checkout.

All 9 GameInput fake-host tests pass, including:

  • callbacks_from_registration_and_poll_are_serialized
  • blocking_enumeration_finishes_on_registering_thread_while_poll_delivers
  • blocking_enumeration_reports_devices_connected_during_its_callback

This exercises the revised completion/thread and hotplug-ordering assertions, rather than the older revision discussed in the earlier Wine report.

Full workspace unit/integration comparison:

Configuration Passed Failed Ignored
Unmodified ffe310e 341 5 6
Same main + this PR 344 5 6

All 14 Windows test executables were built with cargo test --workspace --all-features --locked --offline --target x86_64-pc-windows-msvc --no-run and run under Wine with --nocapture --test-threads=1. The HLE crate changes from 93 passed / 1 failed to 96 passed / 1 failed. No new failures appeared.

The five shared failures are the existing Wine missing-Winsock-export test (only_loopback_is_reachable), nested Cargo fixture build (loads_binds_and_calls_probe), empty pipeline library (a_rejected_blob_gives_an_empty_library, addressed separately by #347), shader-checksum rejection expectation (stub_pipeline_is_created), and Windows xtask's inability to run host Git (repository_passes_policy). Native Linux cargo test -p xtask separately passes all four tests, asset policy passes, and Windows-target HLE Clippy with all targets/features and -D warnings passes.

Environment: Rust 1.98.1, Wine 11.22, Linux, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton 30b0eb9bc12dc9f with app-local DXVK and native d3dcompiler_47 for the GPU fixtures. Both full-suite configurations use the same runtime and compiler DLLs. Tests ran offline under Xvfb; the GameInput tests use fake devices.

Limits: no physical-controller or gameplay test, native Windows/WARP run, or Wine doctests. Some existing tests return early when optional console compilers or the DXIL validator are absent; the aggregate does not establish coverage of those paths. No game files or generated game data were used or attached.

AI-assisted testing with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135524549 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7135524549). Originally posted by [ThomasHFWright](https://github.com/ThomasHFWright) on 2026-11-24T15:08:28Z. --- Re-tested the revised callback implementation at `7da55befe68142103d81110c5eaab47a8f4d6b43` under Wine, with this PR's complete diff applied to current `main` `ffe310eb2098e52169f4c44db5ffdabf43a72622` in an isolated checkout. All **9 GameInput fake-host tests pass**, including: - `callbacks_from_registration_and_poll_are_serialized` - `blocking_enumeration_finishes_on_registering_thread_while_poll_delivers` - `blocking_enumeration_reports_devices_connected_during_its_callback` This exercises the revised completion/thread and hotplug-ordering assertions, rather than the older revision discussed in the earlier Wine report. Full workspace unit/integration comparison: | Configuration | Passed | Failed | Ignored | | --- | ---: | ---: | ---: | | Unmodified `ffe310e` | 341 | 5 | 6 | | Same main + this PR | 344 | 5 | 6 | All 14 Windows test executables were built with `cargo test --workspace --all-features --locked --offline --target x86_64-pc-windows-msvc --no-run` and run under Wine with `--nocapture --test-threads=1`. The HLE crate changes from **93 passed / 1 failed** to **96 passed / 1 failed**. No new failures appeared. The five shared failures are the existing Wine missing-Winsock-export test (`only_loopback_is_reachable`), nested Cargo fixture build (`loads_binds_and_calls_probe`), empty pipeline library (`a_rejected_blob_gives_an_empty_library`, addressed separately by #347), shader-checksum rejection expectation (`stub_pipeline_is_created`), and Windows xtask's inability to run host Git (`repository_passes_policy`). Native Linux `cargo test -p xtask` separately passes all four tests, asset policy passes, and Windows-target HLE Clippy with all targets/features and `-D warnings` passes. Environment: Rust 1.98.1, Wine 11.22, Linux, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton `30b0eb9bc12dc9f` with app-local DXVK and native `d3dcompiler_47` for the GPU fixtures. Both full-suite configurations use the same runtime and compiler DLLs. Tests ran offline under Xvfb; the GameInput tests use fake devices. Limits: no physical-controller or gameplay test, native Windows/WARP run, or Wine doctests. Some existing tests return early when optional console compilers or the DXIL validator are absent; the aggregate does not establish coverage of those paths. No game files or generated game data were used or attached. AI-assisted testing with Codex.
Marvisak commented 2026-11-25 02:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:28:34Z.


Automated triage for the maintainers.

Merge candidate.

Hub::deliver (crates/victory-hle/src/modules/gameinput.rs) is replaced by a queue in State that one thread drains (claim_delivery, drain, invoke). Callbacks from poll and from registration therefore no longer overlap. invoke checks the registration and marks it running under the same lock, so UnregisterCallback still waits for a callback that is running.

The blocking-enumeration issue raised in review is fixed in 7da55bef. If another thread is already delivering, register_device runs that registration's initial callbacks on the calling thread, which avoids a deadlock. It holds back that registration's hotplug events in State::enumerating until enumeration ends, so RegisterDeviceCallback returns only after its initial callbacks have run. The three new tests cover serialization, completion on the registering thread, and a hotplug during enumeration.

Known trade-off: in that one inline case, the registering thread's enumeration callbacks can run at the same time as another registration's callback on the poll thread. Contention is the price of not blocking there.

Optional cleanup: forget could also prune state.queue. It isn't needed for correctness, because invoke skips unregistered tokens.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149588486 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7149588486). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:28:34Z. --- <!-- victory-triage v1 head=7da55befe68142103d81110c5eaab47a8f4d6b43 verdict=merge-candidate at=2026-11-25T01:28:33Z --> Automated triage for the maintainers. **Merge candidate.** `Hub::deliver` (`crates/victory-hle/src/modules/gameinput.rs`) is replaced by a queue in `State` that one thread drains (`claim_delivery`, `drain`, `invoke`). Callbacks from `poll` and from registration therefore no longer overlap. `invoke` checks the registration and marks it running under the same lock, so `UnregisterCallback` still waits for a callback that is running. The blocking-enumeration issue raised in review is fixed in `7da55bef`. If another thread is already delivering, `register_device` runs that registration's initial callbacks on the calling thread, which avoids a deadlock. It holds back that registration's hotplug events in `State::enumerating` until enumeration ends, so `RegisterDeviceCallback` returns only after its initial callbacks have run. The three new tests cover serialization, completion on the registering thread, and a hotplug during enumeration. Known trade-off: in that one inline case, the registering thread's enumeration callbacks can run at the same time as another registration's callback on the poll thread. Contention is the price of not blocking there. Optional cleanup: `forget` could also prune `state.queue`. It isn't needed for correctness, because `invoke` skips unregistered tokens. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:02:41 +00:00
Marvisak commented 2026-11-25 22:04:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T21:59:07Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because what the title needs from device callbacks is already in main, and this adds risk on a path every boot runs. The title's two registrations are blocking, and the keyboard one is made under a lock that its own callback takes again, so the enumeration has to run on the registering thread, which main does. The races closed here need a pad to connect or disconnect in the microseconds between a registration's snapshot and its enumeration. Against that, the new delivery state still runs callbacks on two threads at once in the inline case, and the registering thread can end up draining other registrations' callbacks while it holds that lock. The public RegisterDeviceCallback page does not promise one callback at a time across registrations either.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175789708 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/613#issuecomment-7175789708). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T21:59:07Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because what the title needs from device callbacks is already in `main`, and this adds risk on a path every boot runs. The title's two registrations are blocking, and the keyboard one is made under a lock that its own callback takes again, so the enumeration has to run on the registering thread, which `main` does. The races closed here need a pad to connect or disconnect in the microseconds between a registration's snapshot and its enumeration. Against that, the new delivery state still runs callbacks on two threads at once in the inline case, and the registering thread can end up draining other registrations' callbacks while it holds that lock. The public `RegisterDeviceCallback` page does not promise one callback at a time across registrations either. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!613
No description provided.