[Bug + Patch] Synchronous HID rumble + Hub::source locking causes 200-1200ms frame stalls with DualSense/DS4 #272

Open
opened 2026-12-01 07:59:32 +00:00 by github-bot · 0 comments
Owner

@⁠giangero1 on GitHub · 2026-12-01 07:57 UTC · original

foxhound version: 593067c8 (bug still present up to 297f58ae — crates/victory-hle/src/modules/gameinput unchanged since 45e2dec8)

GPU / CPU / RAM / Windows: RTX 3070 8 GB / Ryzen 7 5800X3D / 32 GB DDR4 / Windows 10 (19045)

Launcher settings (resolution, DLSS, Frame Generation, VRAM limit): Series S, 1080p, DLSS Performance, FrameGen OFF, VICTORY_HOST_WAVE=32, VICTORY_POOL_SMALL=1, VICTORY_TEXTURE_ROOM_PERCENT=75, VICTORY_CARD_ROOM_FOR_TARGETS_MB=1024, VICTORY_CARD_WINDOWS_MB=256, VICTORY_HELPER_PRIORITY=1

What happens, and when:
During gameplay sections with continuous controller vibration (DualSense USB 054c:0ce6), title worker threads repeatedly stalled inside hid.dll (NtQueryInformationFile / NtDeviceIoControlFile), dropping frame rate to 8–16 FPS with 237–1230.4 ms worst frame spikes (2–5 >100 ms per second) and 55–274 ms GPU starvation (12–42% GPU busy):

  1. hid.rs: Pads::rumble calls HidD_SetOutputReport on the same synchronous CreateFileW(..., 0, ...) handle that hid-pad holds in a blocking ReadFile, serializing every rumble report behind the next input report (~4.55 ms measured vs ~0.045 ms on a separate write handle).
  2. gameinput.rs: Live set_rumble runs synchronously on title worker threads while holding Hub::source Mutex and triggers periodic HID enumeration / XInputGetState polling.

Isolated 1-commit fix (2 files only, built off 593067c8):

  • Commit: github.com/giangero1/VIctory-RTX3070-8GB@8f6597604b
  • Branch: https://github.com/giangero1/VIctory-RTX3070-8GB/tree/fix/nonblocking-hid-rumble
  • Touches strictly crates/victory-hle/src/modules/gameinput.rs and crates/victory-hle/src/modules/gameinput/hid.rs:
    • Opens a separate write_handle for DualSense/DS4 output reports on an 8 ms coalescing hid-rumble writer thread (immediate (0, 0) stop; caches rejected non-gamepad HID collection paths).
    • Routes live set_rumble via a non-blocking RumbleMailbox (gameinput-rumble) without locking Hub::source, keeping synthetic Fake unit tests synchronous.
    • Passes cargo xtask policy (292 files ok), cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --locked -p victory-hle gameinput (25 passed; 0 failed).

After-fix measurements (same scene & settings):
Frame pacing in sustained-rumble gameplay went from 8–16 FPS (237–1230.4 ms max, 55–274 ms GPU idle gaps) to 24–26 FPS (36.1–46.2 ms median, 66.5–67.1 ms max, 0 frames >100 ms, GPU 94–98% busy with 1.0–2.3 ms queued gaps).

Log excerpt (before vs. after):

# BEFORE (title worker blocked inside hid.dll via Pads::rumble):
  tid=9200 name="" start=title+0x2215ea0 dkcycles=40 rip=ntdll!NtQueryInformationFile+0x14 stack=[hid+0x1a56 | gpu::heap::_::__rust_alloc_zeroed+0x24 | hid+0x3b39 | hle::gameinput::hid::devices::Pads::rumble+0x94 | hle::gameinput::host::impl$1::pad+0xb4] gap_ms=160 seq=71132
INFO victory_gpu::frame_times: frame times: 18 frames, median 53.7 ms, p95 185.1, p99 397.9, longest 397.9; 10 over 50 ms, 3 over 100 ms
INFO victory_gpu::host: the card's clock per frame: nothing of ours queued 74.6 ms (the card about 21% busy by this count)

# AFTER (8f659760):
INFO victory_gpu::frame_times: frame times: 33 frames, median 30.4 ms, p95 44.7, p99 57.5, longest 57.5; 1 over 50 ms, 0 over 100 ms
INFO victory_gpu::host: the card's clock per frame: nothing of ours queued 1.9 ms (the card about 94% busy by this count), 1.8 ms of that while the submitting thread was working (the card idle behind us), the rest while the title had not submitted; the submitting thread stood waiting for the card 0.8 ms
INFO victory_gpu::frame_times: frame times: 33 frames, median 30.9 ms, p95 44.2, p99 47.3, longest 47.3; 0 over 50 ms, 0 over 100 ms
**@⁠giangero1** on GitHub · 2026-12-01 07:57 UTC · [original](https://github.com/readmet3xt-lab/foxhound/issues/272) **foxhound version:** `593067c8` (bug still present up to `297f58ae` — `crates/victory-hle/src/modules/gameinput` unchanged since `45e2dec8`) **GPU / CPU / RAM / Windows:** RTX 3070 8 GB / Ryzen 7 5800X3D / 32 GB DDR4 / Windows 10 (19045) **Launcher settings (resolution, DLSS, Frame Generation, VRAM limit):** Series S, 1080p, DLSS Performance, FrameGen OFF, `VICTORY_HOST_WAVE=32`, `VICTORY_POOL_SMALL=1`, `VICTORY_TEXTURE_ROOM_PERCENT=75`, `VICTORY_CARD_ROOM_FOR_TARGETS_MB=1024`, `VICTORY_CARD_WINDOWS_MB=256`, `VICTORY_HELPER_PRIORITY=1` **What happens, and when:** During gameplay sections with continuous controller vibration (DualSense USB `054c:0ce6`), title worker threads repeatedly stalled inside `hid.dll` (`NtQueryInformationFile` / `NtDeviceIoControlFile`), dropping frame rate to `8–16 FPS` with `237–1230.4 ms` worst frame spikes (`2–5` >100 ms per second) and `55–274 ms` GPU starvation (`12–42%` GPU busy): 1. `hid.rs`: `Pads::rumble` calls `HidD_SetOutputReport` on the same synchronous `CreateFileW(..., 0, ...)` handle that `hid-pad` holds in a blocking `ReadFile`, serializing every rumble report behind the next input report (~`4.55 ms` measured vs ~`0.045 ms` on a separate write handle). 2. `gameinput.rs`: Live `set_rumble` runs synchronously on title worker threads while holding `Hub::source` Mutex and triggers periodic HID enumeration / `XInputGetState` polling. **Isolated 1-commit fix (2 files only, built off `593067c8`):** - Commit: https://github.com/giangero1/VIctory-RTX3070-8GB/commit/8f6597604b57b1ae8d3711b8daf4b445fa4a9a38 - Branch: https://github.com/giangero1/VIctory-RTX3070-8GB/tree/fix/nonblocking-hid-rumble - Touches strictly `crates/victory-hle/src/modules/gameinput.rs` and `crates/victory-hle/src/modules/gameinput/hid.rs`: - Opens a separate `write_handle` for DualSense/DS4 output reports on an `8 ms` coalescing `hid-rumble` writer thread (immediate `(0, 0)` stop; caches rejected non-gamepad HID collection paths). - Routes live `set_rumble` via a non-blocking `RumbleMailbox` (`gameinput-rumble`) without locking `Hub::source`, keeping synthetic `Fake` unit tests synchronous. - Passes `cargo xtask policy` (`292 files ok`), `cargo clippy --workspace --all-targets --locked -- -D warnings`, and `cargo test --locked -p victory-hle gameinput` (`25 passed; 0 failed`). **After-fix measurements (same scene & settings):** Frame pacing in sustained-rumble gameplay went from `8–16 FPS` (`237–1230.4 ms` max, `55–274 ms` GPU idle gaps) to **`24–26 FPS`** (`36.1–46.2 ms` median, `66.5–67.1 ms` max, **`0` frames >100 ms**, GPU **`94–98%` busy** with `1.0–2.3 ms` queued gaps). **Log excerpt (before vs. after):** ```text # BEFORE (title worker blocked inside hid.dll via Pads::rumble): tid=9200 name="" start=title+0x2215ea0 dkcycles=40 rip=ntdll!NtQueryInformationFile+0x14 stack=[hid+0x1a56 | gpu::heap::_::__rust_alloc_zeroed+0x24 | hid+0x3b39 | hle::gameinput::hid::devices::Pads::rumble+0x94 | hle::gameinput::host::impl$1::pad+0xb4] gap_ms=160 seq=71132 INFO victory_gpu::frame_times: frame times: 18 frames, median 53.7 ms, p95 185.1, p99 397.9, longest 397.9; 10 over 50 ms, 3 over 100 ms INFO victory_gpu::host: the card's clock per frame: nothing of ours queued 74.6 ms (the card about 21% busy by this count) # AFTER (8f659760): INFO victory_gpu::frame_times: frame times: 33 frames, median 30.4 ms, p95 44.7, p99 57.5, longest 57.5; 1 over 50 ms, 0 over 100 ms INFO victory_gpu::host: the card's clock per frame: nothing of ours queued 1.9 ms (the card about 94% busy by this count), 1.8 ms of that while the submitting thread was working (the card idle behind us), the rest while the title had not submitted; the submitting thread stood waiting for the card 0.8 ms INFO victory_gpu::frame_times: frame times: 33 frames, median 30.9 ms, p95 44.2, p99 47.3, longest 47.3; 0 over 50 ms, 0 over 100 ms ```
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:59:32 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.