A Report ID item is a HID global item: it stays in effect until it
is changed, so it is valid before the first Collection item. The
WebHID parsing algorithm sets
globalState["reportId"] unconditionally
(hid.spec.whatwg.org).
Chromium's report descriptor parser only updated the current report ID while a
collection was open, so every report in the collection that followed was
parsed with report ID 0 and the device looked like it does not use report IDs
at all.
The test case in the issue uses Usage (Keyboard), whose reports
are always protected by WebHID and therefore unreadable from a page. This
sampler keeps the same shape but on a vendor-defined usage page.
0x85, 0x01, // Report ID (1) <-- before any collection
0x06, 0x00, 0xFF, // Usage Page (Vendor 0xFF00)
0x09, 0x01, // Usage (0x01)
0xA1, 0x01, // Collection (Application)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x95, 0x02, // Report Count (2)
0x09, 0x02, // Usage (0x02)
0x81, 0x02, // Input (Data,Var,Abs)
0x09, 0x03, // Usage (0x03)
0x91, 0x02, // Output (Data,Var,Abs)
0xC0 // End Collection
1. Flash one of the sketches below (Adafruit Feather nRF52840 Express, or an
ESP32-S3 / S2 devkit on its native USB port).
2. On Linux, install 99-hid-reportid-repro.rules so Chrome may
open the hidraw node, then replug the board.
3. Click Connect device below and pick HID ReportID Repro.
4. Repeat on a build with CL 8669861
applied and compare the verdict.
| Check | Expected (per spec) | Actual (unpatched Chrome) |
|---|---|---|
collections[0].inputReports[0].reportId | 1 | 0 |
collections[0].outputReports[0].reportId | 1 | 0 |
sendReport(1, ...) | resolves | rejects |
sendReport(0, ...) | rejects | resolves |
inputreport event .reportId | 1 | 0 |
| Check | Value | Result |
|---|---|---|
inputReports[0].reportId | - | - |
outputReports[0].reportId | - | - |
sendReport(1, ...) | - | - |
sendReport(0, ...) | - | - |
inputreport event .reportId | - | - |
Log output appears here.
Issue: crbug.com/574273446
Fix CL: crrev.com/c/8669861
Spec: WebHID, parsing the report descriptor
Parser: services/device/hid/hid_collection.cc