Skip to content

usb-device-mouse: send_report() blocks forever if the host never reads the mouse #1178

Open

Description

@Duhan07

Description

MouseInterface.send_report() waits for the previous report with no timeout:

while self.busy():
    machine.idle()

If the host never reads the mouse IN endpoint, the first report stays pending and the next move_by() / click_*() never returns. The whole
program freezes, including other interfaces such as a KeyboardInterface on the same device.

HIDInterface.send_report() already has a 100 ms timeout, but it is never reached, because MouseInterface.send_report() waits before calling it.

When does the host not read the mouse?

For example a UEFI firmware with a keyboard driver but no mouse driver. I saw it with EDK2/OVMF (QEMU 11.1.3, edk2-stable202408) and the device passed through with usb-host: EDK2 sends SET_PROTOCOL(boot) to the keyboard and no request at all to the mouse interface.

Reproduction

  • MicroPython v1.29.0, ESP32_GENERIC_S3, usb-device-keyboard, usb-device-mouse
  • KeyboardInterface + MouseInterface, a button that sends one key and then 20 mouse.move_by() calls.

In EDK2 the first press sends the key, then the program hangs in the loop above; no later press is seen. With my own 50 ms timeout before each move_by() the program keeps running, and it logs that 19 of 20 moves were skipped on the first press and 20 of 20 on every later press.

Possibly the same symptom as #1131 (closed by its author).

Suggested fix

Give the loop a timeout and return False without touching _buf, the same way HIDInterface.send_report() does.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions