Skip to content
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

Chromium only partially supports WebUSB API in web workers #24639

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

skyclouds2001
Copy link
Contributor

@skyclouds2001 skyclouds2001 commented Oct 5, 2024

Summary

the WebUSB API is not exposed to shared worker and service worker (except for webextension service workers) in chromium, which should be according to the spec

no related browser issue is found

see chromium source code

this can be test using https://worker-playground.glitch.me/

Note: I'm not sure if partial_implementation or impl_url key should be added or not


so full chain is:

  1. expose to dedicated worker (M70)

    chromium/chromium@841d469
    chromium/chromium@3267532
    chromium/chromium@6ed4277
    https://chromium-review.googlesource.com/c/chromium/src/+/1014196
    https://chromium-review.googlesource.com/c/chromium/src/+/1053063
    https://chromium-review.googlesource.com/c/chromium/src/+/1153222
    https://issues.chromium.org/issues/40573868
    https://issues.chromium.org/issues/40575664
    https://chromestatus.com/feature/5928209916887040

  2. expose to webextension service worker (M118)

    chromium/chromium@cf53ee2
    https://chromium-review.googlesource.com/c/chromium/src/+/3894652
    https://issues.chromium.org/issues/40217296
    https://chromestatus.com/feature/5200265459269632

Test results and supporting details

Related issues

@github-actions github-actions bot added the data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Oct 5, 2024
@skyclouds2001 skyclouds2001 marked this pull request as ready for review October 5, 2024 10:29
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please provide more details?

  1. The source code link points only to the webusb directory.
  2. Can you share the test you used, and did you also test in an older Chrome?

@skyclouds2001
Copy link
Contributor Author

skyclouds2001 commented Oct 8, 2024

  1. The source code link points only to the webusb directory.

Because all webusb features is under this folder, and list all webuse idl files is awful. And most idl files are in the same expose scope. like https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/webusb/usb.idl.

2. Can you share the test you used

The test is check if the specific interface is exposed to one of the worker scope.

Also, I found I make a mistake, that the feature is also available in WebExtension service workers. see https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5;l=4850

And as #24538 did, I've instead to use a separate worker_support field to store the data (except for WorkerNavigator.usb).

did you also test in an older Chrome?

Not at this moment.

api/USB.json Outdated Show resolved Hide resolved
api/USBAlternateInterface.json Outdated Show resolved Hide resolved
api/USB.json Outdated Show resolved Hide resolved
api/USBAlternateInterface.json Outdated Show resolved Hide resolved
api/USBConfiguration.json Outdated Show resolved Hide resolved
api/USBConfiguration.json Outdated Show resolved Hide resolved
api/USBConnectionEvent.json Outdated Show resolved Hide resolved
api/USB.json Outdated Show resolved Hide resolved
@caugner caugner changed the title Add notes to WebUSB API to indicate it is not exposed to Shared Worker and Service Worker in chromium Chromium only partially supports WebUSB API in web workers Oct 9, 2024
@caugner caugner merged commit 5722a18 into mdn:main Oct 9, 2024
6 checks passed
@skyclouds2001 skyclouds2001 deleted the webusb branch October 9, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants