[Bug]: Throttled move and scroll events are dropped, so the cursor travels less than the finger/mouse

Open
#452 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Piyush0000 is already working on this.

Since Nov 23, 2026.

  • #453 by @mayank609 — closed without merging
  • #520 by @Piyush0000 — open
  • #521 by @deba2k5 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
15/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
backend

Research direction

Start in src/server/InputHandler.ts at throttle(), where a new message overwrites pendingMove or pendingScroll inside the throttle window. Pointer-lock input in useMouseInput.ts shows the high-rate case. Done means dx/dy are summed into the pending message and a unit test with a mocked injector and fake timers passes. Pull request #453 is already open against this issue, so check it before starting.

Written by the indexing model from the issue text.

Description

bug
Bug Description

InputHandler.throttle() drops cursor movement and scroll distance when events arrive faster than the throttle window (8 ms).

move and scroll messages carry relative deltas (dx, dy). When a message arrives inside the throttle window, it's stored in pendingMove / pendingScroll, and each new message overwrites the previous pending one:

if (now - this[lastKey] < this.throttleMs) {
	this[pendingKey] = msg   // earlier pending dx/dy are lost

Only the last message in each window is applied, so the cursor travels less than the user's finger or mouse did.

This happens when:

  • Network jitter delivers several frame-batched touch moves at once
  • Pointer-lock mouse mode (useMouseInput.ts) sends every mousemove without batching, so a high-rate mouse sends far more than one event per 8 ms

I simulated the current logic with 120 moves of 10 px each:

Arrival pattern Sent Applied now Lost
Steady 60 Hz / 120 Hz 1200 px 1200 px 0%
60 Hz with jitter (bursts of 3) 1200 px 800 px 33%
1 ms apart (high-rate mouse) 1200 px 160 px 87%
Steps to Reproduce
  1. Connect a client and use the trackpad on a slow or jittery Wi-Fi link, or use pointer-lock mouse mode with a high polling rate mouse.
  2. Move the same physical distance quickly vs. slowly.
  3. The fast movement moves the cursor noticeably less, and scrolling skips.
Expected Behavior

Throttling should limit how often the OS input is injected, without losing distance. Deltas that arrive inside the throttle window should be summed into the pending message, so a 5-event burst of dx: 10 still moves the cursor 50 px.

Desktop Operating System

All (the logic is in the platform-independent src/server/InputHandler.ts)

Client OS and browser

All

Rein Version

main @ 4efa9a8

Proposed fix

Merge dx/dy of the new message into the existing pending message instead of replacing it (about 8 lines in throttle()), and add a unit test with a mocked injector and fake timers. I'd like to work on this.

Dominant language
TypeScript
Stars
55
Forks
120
Avg merge
4d 5h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/Rein

All issues in AOSSIE-Org/Rein

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.