Intent to Ship: WebHID exclusionFilters option in requestDevice()

105 views
Skip to first unread message

François Beaufort 🇫🇷

unread,
Mar 24, 2022, 11:51:25 PM3/24/22
to blink-dev

Contact emails

fbea...@google.com

mattre...@google.com


Explainer

https://github.com/WICG/webhid/blob/main/EXPLAINER.md


Specification

https://wicg.github.io/webhid/#dom-hiddevicerequestoptions-exclusionfilters

https://github.com/WICG/webhid/pull/93


Summary

The "exclusionFilters" option in navigator.hid.requestDevice() allows web developers to exclude some devices from the browser picker. It can be used to exclude devices that are known to be malfunctioning.


Blink component

Blink>HID


Motivation

Allowing web developers, through the "exclusionFilters" option, to exclude directly from the browser picker some devices that are known to not function in a way that suits the site will improve user experience. Without it, web developers let users pick a device, then have to check against a custom JavaScript helper function (like deviceIsBlocklisted()) whether device is known to be malfunctioning and if that’s the case alert users the device they’ve picked is not suitable, resulting in a poor user experience.


// Request access to a device with vendor ID 0xABCD. The device must also have a

// collection with usage page Consumer (0x000C) and usage ID Consumer Control

// (0x0001). The device with product ID 0x1234 has been reported as malfunctioning.

const devices = await navigator.hid.requestDevice({

  filters: [{ vendorId: 0xabcd, usagePage: 0x000c, usage: 0x0001 }],

  exclusionFilters: [{ vendorId: 0xabcd, productId: 0x1234 }],

});


TAG review

This small addition to the WebHID API doesn’t seem to qualify for a TAG review. I’m happy to file one if desired though.


TAG review status

Not Applicable


Risks


Interoperability and Compatibility


This small addition to the HIDDeviceRequestOptions dictionary does not change the overall status of WebHID interoperability or compatibility.


Signals from other implementations (Gecko, WebKit): 


Gecko: No Signal [1]

WebKit: No Signal [1]

Web / Framework developers: Positive https://github.com/WICG/webhid/issues/92

  Other signals: Google Meet folks have asked for this addition and strongly support this.


[1] Both Gecko and WebKit are unlikely to object to this feature specifically, but object to the overall WebHID API as a whole, hence it doesn't make sense to bug them with specific questions on this.


Activation:

This feature can't be polyfilled. It should be fairly trivial for developers to adopt this new feature.


Debuggability

No specific DevTools changes are required. This feature is treated like any other JS method.

Note that exposing DevTools debugging support for device-access APIs (WebHID included) is discussed at https://bugs.chromium.org/p/chromium/issues/detail?id=1142566.


Is this feature fully tested by web-platform-tests?

No, because browser picker implementation is implemented outside of Blink and so isn’t testable by web-platform-tests. 


Requires code in //chrome?

Yes, browser picker implementation lives in //chrome.


Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=1301934


Estimated milestones

102


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5194022623641600



Mike Taylor

unread,
Mar 26, 2022, 1:37:38 PM3/26/22
to François Beaufort 🇫🇷, blink-dev
LGTM1

Manual tests should be possible, right?


Requires code in //chrome?

Yes, browser picker implementation lives in //chrome.


Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=1301934


Estimated milestones

102


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5194022623641600



--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAPpwU5JYJCYBgmg9Kr6G%2Bt7yH5iU_X_3QJhO-_8rk%3DjYW%2BLsYQ%40mail.gmail.com.


François Beaufort 🇫🇷

unread,
Mar 28, 2022, 10:40:07 AM3/28/22
to Mike Taylor, blink-dev
The problem with manual tests in that specific case is that we don't know which HID devices would be presented in the browser picker.
They depend on the tester machine and/or what testers own.

See https://groups.google.com/a/chromium.org/g/blink-dev/c/rL1csFYD1Ms/m/g7nxWoROCQAJ for more information on WebHID web platform tests. 

Daniel Bratell

unread,
Mar 28, 2022, 1:33:51 PM3/28/22
to François Beaufort 🇫🇷, Mike Taylor, blink-dev

Yoav Weiss

unread,
Mar 28, 2022, 2:51:30 PM3/28/22
to Daniel Bratell, François Beaufort 🇫🇷, Mike Taylor, blink-dev
Reply all
Reply to author
Forward
0 new messages