Skip to content

fix(rustdesk): reduce relative mouse latency under video load - #308

Open
drgnchan wants to merge 1 commit into
mofeng-git:devfrom
drgnchan:fix/rustdesk-mouse-latency
Open

fix(rustdesk): reduce relative mouse latency under video load#308
drgnchan wants to merge 1 commit into
mofeng-git:devfrom
drgnchan:fix/rustdesk-mouse-latency

Conversation

@drgnchan

@drgnchan drgnchan commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • move RustDesk video/audio socket writes out of the connection read loop so backpressured media writes do not delay keyboard and mouse dispatch
  • serialize outbound encryption and framing in a shared writer to preserve nonce and wire ordering
  • accumulate throttled relative mouse deltas instead of dropping displacement
  • split accumulated movement into signed 8-bit HID reports and flush pending movement before button/wheel events

Why

The MJPEG console remained responsive on the same device and HID backend, while RustDesk relative mouse movement lagged behind. Two RustDesk-specific paths contributed:

  1. Media writes and incoming input reads were handled by the same tokio::select! loop. A blocked video write prevented the loop from polling the socket reader.
  2. Relative movement arriving inside the 16 ms throttle window was discarded. Unlike absolute coordinates, later relative events cannot recover that lost displacement.

Validation

  • cargo check --release --target armv7-unknown-linux-gnueabihf
  • cargo build --release --target armv7-unknown-linux-gnueabihf
  • deployed the ARMv7 release build to an One-KVM device using USB OTG HID and relative mouse mode
  • manual RustDesk comparison showed substantially improved cursor tracking

@mofeng-git
mofeng-git changed the base branch from main to dev September 6, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant