Chrome 89 launched WebHid API with limitations for security.
Limitations includes:
Javascript cannot receive USB Hid data when browser tab switched.
Javascript cannot receive USB Hid data when user is opening select html element
..... more in the link
There is a commit in Chromium project says that The blocklist may be bypassed by passing allow_protected_reports=true when connecting to the devic
.
Is there a way to set allow_protected_reports=true
to bypass these limitations on UI such as chrome://flags
?
related link: https://web.dev/hid/#security-privacy
2021.10.28 update
MacOS BigSur 11.2.3
Chrome Version 95.0.4638.54 (Official Build) (x86_64)
For reproducing the limitation:
Javascript cannot receive USB Hid data when user is opening select html element
<select>
<option> test </option>
</select>
device.addEventListener("inputreport", (e) => {
const data = e.data.buffer;
console.log(new Date(), "received data", data);
});
When the user click the "test" select element to open it, it will stop receiving data.
working example on codesandbox
Javascript cannot receive USB Hid data when browser tab switched
.
I cannot reproduce it every time on my mac+chrome now, I did receiving hid device data via API device.addEventListener("inputreport",...)
in a simple testing environment when the tab switched.
But I found it stopped in my real production React.js application which running much more javascript and timers ( setInterval ).