-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose WebHID to Web Workers #120
Comments
My naive understanding is that it would be similar to WebUSB on Workers |
Indeed, and that proposal was already accepted: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers#web_apis_available_in_workers |
@nondebug @chengweih001 I'm happy to update the spec and implement this in Chromium following what was done for WebUSB if that helps |
FYI, I've started a Chromium CL that adds support for Dedicated Workers to WebHID at https://chromium-review.googlesource.com/c/chromium/src/+/5841991 and it works great (so far) on my machine ! I've created https://webhid-worker.glitch.me/ to play with it. |
Looks great! I will test it with our devices too. BTW: why only dedicated workers and not shared ones as well? Thank you for the quick reaction! |
I believe it could be implemented in shared workers as well but I didn't look into it yet. |
How did it go with your devices? |
This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046}
This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046}
This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046}
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <arthursonzognichromium.org> Reviewed-by: Yoav Weiss (Shopify) <yoavweisschromium.org> Reviewed-by: Matt Reynolds <mattreynoldschromium.org> Commit-Queue: Fr <beaufort.francoisgmail.com> Cr-Commit-Position: refs/heads/main{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244 UltraBlame original commit: 091c9c912077b35fe3eb0526c59790da67a80a9a
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <arthursonzognichromium.org> Reviewed-by: Yoav Weiss (Shopify) <yoavweisschromium.org> Reviewed-by: Matt Reynolds <mattreynoldschromium.org> Commit-Queue: Fr <beaufort.francoisgmail.com> Cr-Commit-Position: refs/heads/main{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244 UltraBlame original commit: 091c9c912077b35fe3eb0526c59790da67a80a9a
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <arthursonzognichromium.org> Reviewed-by: Yoav Weiss (Shopify) <yoavweisschromium.org> Reviewed-by: Matt Reynolds <mattreynoldschromium.org> Commit-Queue: Fr <beaufort.francoisgmail.com> Cr-Commit-Position: refs/heads/main{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244 UltraBlame original commit: 091c9c912077b35fe3eb0526c59790da67a80a9a
🎉 Support for dedicated workers in WebHID is now enabled by default in Chrome 131.0.6740.0. |
I can confirm it is working beautifully! Thank you for the quick reaction! PS: we should update the list of APIs available in workers here: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers#web_apis_available_in_workers |
I'm happy about it as well! Please let us know when your web app is ready so that others can try it ;)
@chrisdavidmills may be able to help us! |
@beaufortfrancois sure thing, I can do that. It might also make sense to add browser compat data entries to show when the WebHID interfaces were made available to web workers, in the same style as this: https://github.com/mdn/browser-compat-data/blob/63cd0efe688ecd6a7fe86bf65b09e82762a04b23/api/_globals/indexedDB.json#L50 Can you confirm which interfaces/features of https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API are specifically exposed to workers, so I know where to put these entries? And it is just dedicated workers, for now, correct? |
Thank you @chrisdavidmills! It is just for dedicated workers and service workers for now. See #121
|
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244
@beaufortfrancois mdn/content#36060. Can you provide a tech review? Shouldn't take long, as the vast majority of the changes are just adding "supported in workers" banners to existing pages. |
…s, a=testonly Automatic update from web-platform-tests WebHID: Add support for dedicated workers This CL exposes the WebHID API to dedicated workers behind the blink runtime feature WebHIDOnDedicatedWorkers. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI Spec PR: WICG/webhid#121 Spec issue: WICG/webhid#120 Demo: https://webhid-worker.glitch.me/ Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d Bug: 365932453 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Yoav Weiss (@Shopify) <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357046} -- wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66 wpt-pr: 48244
We are developing an in-browser racing game that relies heavily on gamepads and particularly complex racing wheels and pedals.
Given the differences in hardware, lack of support for Vibration and Haptic Feedback and pooling rather that event-based access, we decided to implement our control layer using WebHID instead of Gamepad API.
To be able to provide the lowest possible latency, we need to make sure the inputs are sent over to the backend ASAP (websockets in our case), without blocking the main thread, hence the need to access this API inside web workers is needed.
We see the same was done for service-workers (in extensions) in #97, so I assume this change is very similar and easy to add, the
requestDevice
should still reside in the main thread only.Hope this is sufficient details for our use-case, otherwise we are happy for an open discussion, CCing @nondebug and @chengweih001 in.
Thank you in advance!
The text was updated successfully, but these errors were encountered: