I'm working in Chrome for MacOS (108.0.5359.124) and Microsoft Edge (107.0.1418.62) on MacOS 12.6.1 (though confirmed the same issue on 13.0.1 as well), and the reset()
method of WebUSB does not seem to work - I get no error on the console, but the device also doesn't see the reset.
Meanwhile, the same code does generate a USB reset in Chrome on Linux (same version, 108.0.5359.124, under Ubuntu 18.04 with kernel 5.4.0).
The code is here:
const connectButton = document.getElementById("connect");
const resetButton = document.getElementById("reset");
let device;
connectButton.onclick = async () => {
device = await navigator.usb.requestDevice({
filters: []
});
await device.open();
console.log("open:", device);
await device.selectConfiguration(1);
console.log("select config 1:", device);
await device.claimInterface(0);
console.log("claim interface 0:", device);
};
resetButton.onclick = async () => {
console.log("Device before reset: ", device);
await device.reset();
console.log("Device after reset:", device);
}
I see all the console logging, and no errors are thrown. (If I try to claim one of the HID interfaces on this device, I do get errors - but I believe that's expected). I've also tried without the device.selectConfiguration()
and device.claimInterface()
calls - exactly the same behavior (ie, no errors, but it doesn't work).
Is there something under MacOS preventing it from sending the reset? I can get similar code working on MacOS under node.js
using WebUSB calls, but I suspect it's actually using libusb
under the hood... I should say that the device in question has firmware written in Zephyr 3.0 (I wrote a substantial part of it). I haven't gotten resets to work with other devices either, though.
CodePudding user response:
According to https://bugs.chromium.org/p/chromium/issues/detail?id=1189418, it seems like USBDevice.reset()
does not work properly on macOS.
Even though a patch was submitted to fix this behaviour, it was reverted due to an expected libusb issue: https://chromium-review.googlesource.com/c/chromium/src/ /2936179
I've pinged the Chromium team at https://bugs.chromium.org/p/chromium/issues/detail?id=1189418#c15. We may want to follow up there.