-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Device chooser for WebUSB #14545
Comments
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines. |
Just commenting here that we won't implement any UI for this, if someone gets to implementing this it would follow the same pattern as the bluetooth API which emits an event with the possible bluetooth devices and leaves the UI up to individual apps. |
Let me know if you have any questions about enabling this. Right now WebUSB isn't hooked up in the easiest way for content embedders but we are refactoring it right now so it should get better. |
@reillyeon Yeah I took a look at this and it's not hooked up to webcontents observer like blueooth is. Might just wait for a refactor 😄 |
Any update on this? Would be helpful for the Electron app of a website I'm building which needs to get the output from a TRNG (true/hardware random-number-generator) usb device. Like mentioned above, there are some NodeJS alternatives, but it would be nice to use the web standard if possible since it means the USB-access code can be shared between the Electron app and the web-only version. |
Any update on this issue? Seems NW.js fixed this over a year ago |
Hi @MarshallOfSound @reillyeon Would you kindly take a look at this and let us know if the refactor has taken place at this point to enable this to go ahead? I checked the USB code in the chromium browser folder and I did not see a WebContentsObserver. Also, I did not see a ticket open to implement this on bugs.chromium.org. I'd like to open a ticket but I do not have your expertise on this matter. Your guidance would be appreciate so that we can get this working in electron. |
The refactoring in Chromium is tracked by issue 991759. This unblocks a whole bunch of things that will help embedders like Electron as well as Headless Chrome and Android WebView. |
@reillyeon Looking at the issue you linked to, am I understanding correctly that Web Serial and WebHID are hooked up to WebContentsObserver? |
I don't believe that either API registers as a WebContentsObserver. They do both access WebContents, but only to update whether or not there are open connections to Serial or HID devices. |
As a subclass of |
Sorry to bring back this dead issue, but there is no other real discussion of it anywhere on the internet. I am attempting to use the webusb polyfill method, and when I try to call requestDevice(), it disconnects the debugger and I do not get a chooser. I have manually specified a device, but when it attempts the requestDevice, it crashes. With the polyfill is there a way to over-ride and select the device manually or was the suggestion above of using a polyfill library misguided? Thank you in advance for any advice. |
@robertguyser this issue is not dead but your question is off-topic. For issues with thegecko/webusb please use that repository's issue tracker. |
Any update on this? Looking to use Electron to talk to a piece of hardware I'm making, would love to use |
Any updates here? Working on an electron app which connects to a mobile device and would like to use the WebUSB api for it. |
I've been looking into using the WebHID API available in Chromium 89 (Electron 12) and later. It looks like this inherits the same permission problem as WebUSB. If anyone wants to kill two birds with one stone, we could get an API similar to |
ah shit here we go again
…On Sun, Jul 11, 2021 at 12:18 PM Jeff Robbins ***@***.***> wrote:
I've been looking into using the WebHID <https://web.dev/hid/> API
available in Chromium 89 (Electron 12) and later. It looks like this
inherits the same permission problem as WebUSB. If anyone wants to kill two
birds with one stone, we could get an API similar to
webContents.on('select-bluetooth-device')
<https://www.electronjs.org/docs/api/web-contents#event-select-bluetooth-device>
for both navigator.usb.requestDevice() and navigator.hid.requestDevice().
Maybe this could all be consolidated into webContents.on('request-device')?
Or not.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14545 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AR3X2BS43BMQXXURBMC6JKLTXG75ZANCNFSM4FUM25JQ>
.
|
How will access to protected interface classes work? It seems ok to ignore that aspect of the spec entirely. Same for the device blocklist. I would like to use Electron for an app the supports discontinued (non-class-compliant) MIDI devices and soundcards, so would really appreciate WebUSB support. |
I have a work-in-progress Chromium change which does the refactoring necessary for //content embedders like Electron to support WebUSB. In that change the new I unfortunately don't have cycles to work on this right now (which is why I uploaded the patch as WIP). If someone wants to take this on I am happy to do code reviews. |
Thank you, @reillyeon. Much appreciated. It's not something I would be competent to take on.
Thanks again. |
The Chromium refactor is complete. Content embedders should implement the https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/usb_delegate.h |
@nornagon Since the Chromium refactor is compelete, I guess the "blocked/upstream" tag can now be removed? |
Is there a conclusion? If not, I'll ask again later |
Also very interested in this. |
I have been monitoring this issue for a few years now. It appears all the backend work in Chromium has been completed. Now the next step is for someone to implement the functionality in Electron. |
I'm getting
and
when trying to claim a USB Audio device. I see there was discussion above regarding AdjustProtectedInterfaceClasses by @reillyeon and @7ombie but I'm not sure if the ability to override which classes are considered "protected" was included in #36289 by @jkleinsc. I can see AdjustProtectedInterfaceClasses in the following file: https://github.com/electron/electron/blob/main/shell/browser/usb/electron_usb_delegate.cc ...but I don't see if this translates to something I can access/configure. Has this been implemented, but I'm missing how to set it? If not, should I open a new ticket/feature request? |
|
Ah that makes more sense, I had been looking at this:
And was assuming that referred to an Electron Context Isolation. Thanks for clearing that up 😄 From my understanding of that comment, and the one shortly below it, if I want to use WebUSB with an audio device, Isolated Web Apps (still in development) and Chrome Apps (Chrome OS only?) are the two options I have |
If you don't mind me asking, why is that something you want to do? |
I have a usb audio interface. The manufacturer discontinued the software for newer versions of macOS. In order to set things like input gains, input selection, or even set volume, I need to send control messages to the hardware. I’d prefer to do this with a web interface as it’s what I’m used to and I can port it easily. |
fwiw I can use electron plus node-usb to work around this. But was gonna have another go at using WebUSB now that this feature is in |
Any updates here? |
Anyone has the WebUSB already working? In my case the "navigator.serial.requestPort()" is not showing up the devices list on Ubuntu. |
Is your feature request related to a problem? Please describe.
Electron has a chooser for Web Bluetooth (#5565), but no chooser for WebUSB. Even if there is only one device, WebUSB still requires the chooser to be used, currently resulting in a
DOMException: No device selected
when callingnavigator.usb.requestDevice()
.WebUSB has been available (without an experimental flag) since Chromium 61.
Describe the solution you'd like
Implement a chooser window like the one in Chromium (see https://cs.chromium.org/chromium/src/chrome/browser/usb/web_usb_chooser.h) to request permission from a user to access a USB device.
Describe alternatives you've considered
node-usb
is an alternative that can be used, but it is barely maintained. WebUSB is well supported by the Chrome team and seems to be the way forward.Additional context
The text was updated successfully, but these errors were encountered: