Device chooser for WebUSB #14545
Device chooser for WebUSB #14545
Comments
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 |
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: