【问题标题】:USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection error with ChromeDriver v87 / Chrome v87 using Selenium on Windows10USB:usb_device_handle_win.cc:1020 在 Windows10 上使用 Selenium 的 ChromeDriver v87 / Chrome v87 无法从节点连接错误中读取描述符
【发布时间】:2026-02-14 18:10:01
【问题描述】:

我们最近使用 ChromeDriver v87.0.4280.20 和 Chrome v87.0.4280.66(官方构建)(64 位)升级了我们的 Windows 10 测试环境,升级后甚至是最小的程序正在生成此错误日志:

[9848:10684:1201/013233.169:ERROR:device_event_log_impl.cc(211)] [01:32:33.170] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

最小代码块:

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get('https://www.google.com/')

控制台输出:

DevTools listening on ws://127.0.0.1:64170/devtools/browser/2fb4bb93-79ab-4131-9e4a-3b65c08dbffb
[9848:10684:1201/013233.169:ERROR:device_event_log_impl.cc(211)] [01:32:33.170] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[9848:10684:1201/013233.172:ERROR:device_event_log_impl.cc(211)] [01:32:33.173] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

有人面临同样的情况吗? ChromeDriver/Chrome v87 相对于 ChromeDriver/Chrome v86 是否有任何变化?有什么线索吗?

【问题讨论】:

    标签: python selenium google-chrome selenium-chromedriver webusb


    【解决方案1】:

    对于日志垃圾邮件,我深表歉意。如果您在使用 WebUSB 连接到设备时没有遇到问题,您可以忽略这些警告。它们由 Chrome 尝试读取当前暂停的 USB 设备的属性触发。

    【讨论】:

    • 无论如何我们不能在日志中显示或隐藏它?
    • @BharadwajGiridhar 我认为我们现在无法抑制错误消息。但是,它将在下一个 Chrome 版本中自动删除。看到这个discussion
    • 感谢@DebanjanB 在您的回答中对我的工作进行了总结,但是您在这里的结论是不正确的。我认为最好降低这些消息的日志级别,这样它们就不会默认出现在控制台上,但我们还没有登陆代码来做到这一点。
    【解决方案2】:

    经过大量讨论、文档和 Chromium 问题,这里是与日志消息显示相关的详细信息:

    [9848:10684:1201/013233.169:ERROR:device_event_log_impl.cc(211)] [01:32:33.170] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
    

    详情

    这一切都始于报告 chromium 问题 Remove WebUSB's dependency on libusb on Windows 为:

    • 对于 Linux(可能还有 Mac),WebUSB 通知和通信都可以正常工作(在 udev 规则中允许用户访问设备之后)。
    • 对于 Windows,似乎 libusb 仅适用于非标准 WinUsb 驱动程序 (https://github.com/libusb/libusb/issues/255)。

    当插入硬件并且系统不知道 VID/PID 时,Windows 10 会正确加载 CDC 部分的 CDC 驱动程序和 WebUSB 部分的 WinUSB 驱动程序(版本 10)(没有危险信号)。但是,chrome 似乎永远找不到设备,直到我在接口上手动强制使用较旧的 WinUSB 驱动程序(版本 6 - 可能也已修改)。

    解决方案按如下逐步实施:

    1. Start supporting some transfers in the new Windows USB backend
    2. Fix bulk/interrupt transfers in the new Windows USB backend
    3. [usb] Read BOS descriptors from the hub driver on Windows
    4. [usb] Collect all composite devices paths during enumeration on Windows
    5. [usb] Remove out parameters in UsbServiceWin helper functions
    6. [usb] Support composite devices in the new Windows backend
    7. [usb] Detect USB functions as Windows enumerates them
    8. [usb] Support composite devices with multiple functions
    9. [usb] Hold interface requests until Windows enumerates functions
    10. [usb] Add direction parameter to ClearHalt
    11. [usb] Count references to a WINUSB_INTERFACE_HANDLE
    12. [usb] Implement blocking operations in the Windows backend

    这些更改确保新后端已准备好进行测试,并可通过 Chrome Canary 和 chrome-dev-channel 访问,您可以通过以下方式手动访问:

    chrome://flags#enable-new-usb-backend
    

    更多变更请求提交如下:

    由于新后端的实验启动看起来很稳定,最后这些配置默认启用,以便将更改推广到Chrome 87usb: Enable new Windows USB backend by default 的所有用户。 Revision / Commit

    我们的想法是,一旦此配置成为一些里程碑的默认配置,Chromium 团队 将开始从旧后端删除特定于 Windows 的代码并删除标志。


    前路

    Chromium 团队已经将 revision/commit 合并到 Chrome v90 中的 Extend new-usb-backend flag expiration,即将推出。


    更新

    根据 @ReillyGrant 的 [Committer, WebDriver for Google Chrome] comment

    ...”最好降低这些消息的日志级别,这样它们就不会默认出现在控制台上,但我们还没有登陆代码来执行此操作”... em>


    参考文献

    您可以在以下位置找到一些相关的详细讨论:

    【讨论】:

    • 您在此答案开头提到的 libusb 问题与 Chrome 退出 libusb 的原因无关。 Chrome 将继续需要 Windows 提供的标准 WinUSB 驱动程序。这与 libusb 支持的驱动程序相同。 libusb 还支持 Chrome 目前不支持的一些非标准驱动程序(libusbk 等)。
    • 非常感谢,我关注了chrome://flags 并启用了Enable new USB backend 选项,之后日志消息就消失了。希望这些更改将默认添加到 Chrome 90 中。
    • 我正在使用带有最新 Win 10 的 Chromedriver V90,并且在运行驱动程序时收到相同的错误消息。唯一的区别是,在我的情况下,错误消息显示 ...win.cc:1054 而不是 1020。我启用了上述评论中提到的 Chrome 标志,但错误仍然存​​在。
    【解决方案3】:

    我昨天遇到了这个问题,我已经通过更新所有可用的 Windows 更新来解决它。

    https://support.microsoft.com/en-us/windows/what-to-try-if-your-touchscreen-doesn-t-work-f159b366-b3ef-99ad-24a4-31a4c62ab46d

    【讨论】:

      【解决方案4】:

      对我有用的部分解决方案

      我也遇到了这个错误。它正在停止我的程序运行。

      1. 我拔掉了所有 USB 设备,运行了程序,没有出现错误。
      2. 重新插入设备,运行程序。我仍然收到错误,但是,程序完成后没有错误停止程序。

      【讨论】:

        【解决方案5】:

        但是,可以通过 hack 添加 add_experimental_option() 来阻止这些日志消息显示在控制台上,如下所示:

        options.add_experimental_option('excludeSwitches', ['enable-logging'])
        

        代码块:

        from selenium import webdriver
        
        options = webdriver.ChromeOptions() 
        options.add_argument("start-maximized")
        # to supress the error messages/logs
        options.add_experimental_option('excludeSwitches', ['enable-logging'])
        driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
        driver.get('https://www.google.com/')
        

        【讨论】:

          最近更新 更多