balena-io / etcher

Flash OS images to SD cards & USB drives, safely and easily.
https://etcher.io/
Apache License 2.0
29.72k stars 2.11k forks source link

Consider implications of WebUSB standard #788

Closed alexandrosm closed 6 years ago

alexandrosm commented 8 years ago

Another one of my ill-defined issues :)

So there is this new standard being proposed -- https://wicg.github.io/webusb/

And I wouldn't really be concerned, except that Chrome already has experimental support for it. image

So there is a chance that Etcher will be able to, at least in theory, work within a browser, maybe some subset of browsers, in the future. For an extended period of time, of course, this will be new/experimental technology. However, since Electron builds on Chromium, we may be in a unique position to have both the latest Chromium code, the ability to enable the API at build time, and have a legitimate use case for it. In other words, Etcher may be able to push or even help improve the standard itself, and gradually increment itself towards being capable of working fully in-browser.

There are a few implications I'm concerned about.

First, what would the theoretical alterations for the Etcher codebase be? Some bullet points:

The interesting thing here is that we already have a good amount of low-level code, and it's almost all in pure js. We've minimised native dependencies to attain npm-installability (in the past), and it's paying out in an unforeseen way. Proposing to run Etcher in the browser is not as insane as it may sound.

Second is what this would mean for Etcher's build/distribution approach if we went fully in-browser:

Finally, what does this mean for Etcher as a project/product.

All in all, I don't see this on our super-short-term roadmap, but it may make sense to experiment with the API, especially if it's available in the Electron version we use, and see what it would take to move some functionality inside the chromium scope.

What does everyone else think?

lurch commented 8 years ago

I had a quick skim through the first page or so, and I wonder if https://wicg.github.io/webusb/#get-allowed-origins means that a USB device would need to explicitly allow http://etcher.io to access it? Which obviously wouldn't be the case for USB Flash drives / SD cards / etc. used with Etcher?

https://github.com/WICG/webusb/blob/gh-pages/explainer.md seems to imply the same thing - sounds like it's more targeted at USB device manufacturers, than software vendors.

alexandrosm commented 8 years ago

Got it. Good to know, and let's put this to sleep till new news emerges.

Alexandros Marinos

Founder & CEO, Resin.io

+1 206-637-5498

@alexandrosm

On Sun, Oct 30, 2016 at 3:18 PM, Andrew Scheller notifications@github.com wrote:

I had a quick skim through the first page or so, and I wonder if https://wicg.github.io/webusb/#get-allowed-origins means that a USB device would need to explicitly allow http://etcher.io to access it? Which obviously wouldn't be the case for USB Flash drives / SD cards / etc. used with Etcher?

https://github.com/WICG/webusb/blob/gh-pages/explainer.md seems to imply the same thing - sounds like it's more targeted at USB device manufacturers, than software vendors.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/resin-io/etcher/issues/788#issuecomment-257183765, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLUCHyXwbtnkBksoHATJufX8rEc0Wb_ks5q5Re6gaJpZM4KkYoy .

tssva commented 7 years ago

Keep in mind that not all card readers are USB attached. For instance the card reader in the Macbook Pro I'm typing this on is PCIe attached.

jobukkit commented 7 years ago

Offline availability is what Service Workers are for.

jhermsmeier commented 6 years ago

Just a note, WebUSB can be enabled in Electron via the experimentalFeatures option;

new BrowserWindow({
  webPreferences: {
    experimentalFeatures: true
  }
})
gniezen commented 6 years ago

@jhermsmeier Have you been able to get WebUSB working in Electron. I get a DOMException: No device selected after calling navigator.usb.requestDevice, as Electron doesn't bring up the USB Device Chooser menu.

jhermsmeier commented 6 years ago

@gniezen I have recently tried this again, and got the same as you did, and tried some workarounds, like disabling user gesture requirement, but that didn't work either.

gniezen commented 6 years ago

I can confirm that WebUSB won't work in Electron until the Device Chooser menu is implemented. I have requested WebUSB support in Electron here: https://github.com/electron/electron/issues/14545

jviotti commented 6 years ago

Let's close this issue!