WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
142 stars 35 forks source link

Intermittent Output Report Issue When Connecting to HID Device #118

Closed KhangxLi closed 1 year ago

KhangxLi commented 1 year ago

Reporting an issue which seems to have been introduced somewhere between Chrome v116 and v117:

In Chrome device log ( chrome://device-log/ ), I see either one of these 2 errors when the issue occurs when connecting to an HID device:

On Chrome versions 117+ (tested on 117, 118, 120), this would happen consistently until Chrome is restarted ( can use chrome://restart ). The issue gets resolved only after a random number of Chrome restarts and sometimes requiring the device to be replugged.

The issue can then be reintroduced after a certain random number of Chrome restarts again. The issue is never reproduced on Chrome v115 and below. Chrome v116 behaviour is untested.

Reproduced both on Windows and Mac.

Potential duplicate:

Opened an issue on the specific library I'm using:

Any ideas?

nondebug commented 1 year ago

Can you share more information about the device?

On macOS, the base64-encoded HID report descriptor is logged in chrome://device-log. For example:

[16:31:43] HID device added: vendorId=1452, productId=34304, name='TouchBarUserDevice', serial='', deviceIds=[4294995179], reportDescriptor='BQEJBqEBhQEFBxkAKf+VBnUIFQAm/wCBAIUCBQwZACn/lQZ1CBUAJv8AgQCFAwYB/xkAKf+VAnUIFQAm/wCBAIUEBf8ZACn/lQR1CBUAJv8AgQDA'

Can you share the reportDescriptor logged in chrome://device-log ?

Output report buffer too long (36 > 2).
This device does not support output reports.

These errors make me think that the device could have multiple HID interfaces and perhaps your app is trying to communicate with the wrong one. When a device has multiple HID interfaces, Chrome shows a single item in the chooser dialog but creates separate HIDDevice objects for each interface. Applications can inspect the HID usages assigned to the top-level collections to distinguish interfaces.

Does your device have multiple HID interfaces? How does your app select the correct interface?

If there are multiple HID interfaces then you should also see multiple "HID device added" messages in chrome://device-log with the same vendorId, productId, name, and serial but different reportDescriptor.

KhangxLi commented 1 year ago

Thanks @nondebug, the issue was indeed selecting the first device in the list. Issue is being discussed in the library I am using as well (https://github.com/SuperFlyTV/xkeys/issues/92).

What's still unknown is why the issue gets exposed in Chromve versions 117+. But otherwise, this issue could be closed.