WICG / webusb

Connecting hardware to the web.
https://wicg.github.io/webusb/
Other
1.32k stars 132 forks source link

add more explanation of how WebUSB on workers deals with multiple threads contending for the same resource #133

Closed dbaron closed 6 years ago

dbaron commented 6 years ago

I got here from w3ctag/design-reviews#277, and this comment relates to the changes made in #130.

It seems to me that there ought to be a little bit more explanation in the spec of how it handles multiple threads trying to interact with the same USB device. In https://github.com/w3ctag/design-reviews/issues/277#issuecomment-386046603 @odejesush wrote:

USB devices are unable to distinguish requests from multiple sources so operating systems only allow an interface to have a single owning user-space or kernel-space driver. In WebUSB, the UA acts as a user-space driver and only allows a single JavaScript execution context to claim an interface at a time. Therefore, it shouldn't be possible for multiple workers to access the same USB device concurrently.

I think this ought to be explained in the specification, perhaps with reference to the exact APIs that will fail when this situation occurs.

odejesush commented 6 years ago

@dbaron I submitted a pull request to add this information to the spec, but I am unable to close this issue.