Repository navigation
Fix Windows slow-IMU partial device: HID gate uses device_path - #15216
Conversation
…ng gate, raise deferral to 10s
sysrsbuild-gh-agentic
left a comment
There was a problem hiding this comment.
[rs-agentic-bot] Automated review — PR #15216
The core fix (switching uvc.id → uvc.device_path) is correct and addresses the root cause clearly. Two inline notes below — one a minor hardening suggestion, one a potential gap in the deferral cap. Additionally, two pre-existing issues noticed while reading the surrounding code that are worth tracking:
🐛 Pre-existing: hdevnotify_sensor handle overwrite in DoRegisterDeviceInterfaceToHwnd
Inside DoRegisterDeviceInterfaceToHwnd, data->hdevnotify_sensor is assigned twice: first for KSCATEGORY_SENSOR_CAMERA, then unconditionally overwritten for GUID_DEVINTERFACE_HID. The first handle is leaked — it is never passed to UnregisterDeviceNotification. This means sensor-camera arrival/removal events are silently re-registered under the HID handle, and the original handle is lost. Relevant lines (pre-existing, not part of this diff):
data->hdevnotify_sensor = RegisterDeviceNotification(hWnd, &di_sensor, ...);
// ... error check ...
data->hdevnotify_sensor = RegisterDeviceNotification(hWnd, &hid_sensor, ...); // ← overwrites previousSuggestion: use a dedicated hdevnotify_hid field for the HID registration, similar to hdevnotifyHW / hdevnotifyUVC.
🐛 Pre-existing: hdevnotifyUSB not unregistered in run() cleanup
The cleanup block at the end of run() unregisters hdevnotifyHW, hdevnotifyUVC, and hdevnotify_sensor, but omits hdevnotifyUSB. This leaks a device-notification registration every time the watcher is stopped.
🧪 Missing tests
No unit tests are added for the hid_binding_in_progress gate logic or the deferral timer behaviour. Given this function guards against a subtle timing race, a test that exercises it with mock backend_device_group snapshots (HID child present/absent in CM tree, Sensor API returning/not returning a matching unique_id) would significantly reduce regression risk. See .github/skills/testing.md for the test infrastructure.
| // never bound) doesn't make the device invisible | ||
| // forever. | ||
| static constexpr auto MAX_DEFERRAL = std::chrono::milliseconds( 5000 ); | ||
| static constexpr auto MAX_DEFERRAL = std::chrono::milliseconds( 10000 ); |
There was a problem hiding this comment.
[rs-agentic-bot]
The PR description states observed IMU binding times of ~6–13 s on D455/D585. Raising MAX_DEFERRAL to 10 s covers the typical case but leaves the 11–13 s tail unprotected: units that bind slower than 10 s will still exhaust the deadline and emit a partial device — the exact failure mode this fix is intended to eliminate.
Suggestions:
- Raise the cap to 15 s (or higher) to cover the full observed range plus headroom — the fallback path for misbehaving/no-HID hardware still triggers correctly after the timeout expires, so the only risk of a larger value is a longer one-time wait on broken hardware.
- Alternatively, expose it as a named constant at file scope (e.g.
HID_BINDING_MAX_DEFERRAL_MS) with a comment documenting the empirical range, making field adjustments straightforward without digging into the logic.
There was a problem hiding this comment.
mostly under 10s, but since some cases are borderline (9s) upped it to 15s
Windows-only fix for the slow-IMU "partial device" race.
The win_event_device_watcher HID-binding deferral gate (hid_binding_in_progress) read uvc_device_info.id, which is only populated by the Linux v4l2 backend and is always empty on Windows (MF sets device_path). The empty path made cm_node::from_device_path resolve nothing, so the gate always returned false and never deferred — the device was emitted as partial (no Motion Module) whenever the IMU HID interface enumerated slower than the UVC interfaces (~6-13s on D455/D585).
Changes (src/mf/mf-backend.cpp):
No-IMU / EOL units are unaffected: no HID-class child -> gate stays false -> they appear immediately with their full sensor set.