Skip to content

Click-and-drag stutters with an 8000 Hz mouse: the synchronous event tap observes every drag event even when no feature needs them #1380

Closed

Description

@eret9616

OS

macOS 15.3.1 (Build 24D70)

LinearMouse

v0.11.4

Describe the bug

With a high polling-rate mouse (Keychron M6 8K, wired, 8000 Hz — ReportInterval = 125 µs in ioreg), click-and-drag stutters badly while LinearMouse is running: the window/selection lags behind the physical mouse and the animation frame rate drops. Plain pointer movement is smooth; only dragging is affected.

  • Quit LinearMouse → dragging is instantly smooth again.
  • Relaunch LinearMouse (fresh process, minutes old) → stutter is back, 100% reproducible.
  • Set the mouse to 1000 Hz → smooth even with LinearMouse running.

It also reproduces on a machine that is otherwise idle (M4 Max, GPU idle, no thermal pressure), so it is not a load issue.

Root cause

GlobalEventTap observes EventType.all, which unconditionally includes leftMouseDragged, rightMouseDragged and otherMouseDragged (but not mouseMoved, which is exactly why only dragging is affected). The tap is created with .defaultTap at .cghidEventTap, i.e. it is synchronous: WindowServer has to round-trip every observed event through LinearMouse before it can deliver it. At 8000 Hz that is up to 8000 blocking round trips per second while a window is being dragged.

Evidence:

  • sudo sample WindowServer during a drag shows SkyLight add_event_vector_to_tap as the hottest frame.
  • A small CGGetEventTapList dump shows LinearMouse's tap is the only enabled synchronous tap on the system whose mask contains leftMouseDragged; the other taps are listen-only or keyboard/scroll only. Its recorded latency spikes into the hundreds of milliseconds.
  • In my configuration nothing can consume drag events for this device — the scheme only sets pointer.disableAcceleration and scrolling.modifiers. Drag events are only useful to button mappings, switchPrimaryButtonAndSecondaryButtons, universalBackForward, autoScroll and gesture.

Even at 1000 Hz this is avoidable overhead (see #915); at 4000–8000 Hz it is the difference between usable and not. #1166 had the same symptom but a different cause (fixed in 0.11.1).

To reproduce

  1. Use a mouse at 4000/8000 Hz (e.g. Keychron M6 8K wired at 8000 Hz). Check with ioreg -r -c IOHIDDevice -l | grep -A3 'M6 8K' | grep ReportInterval → 125.

  2. Configure LinearMouse with only pointer/scrolling settings for that device — no button mappings, no auto scroll, no gesture:

    {
      "if": { "device": { "category": "mouse", "productID": "0xd049", "vendorID": "0x3434" } },
      "pointer": { "disableAcceleration": true },
      "scrolling": { "modifiers": { "vertical": { "command": { "type": "changeSpeed", "scale": 3 } } } }
    }
  3. Drag any window around → stutters.

  4. Quit LinearMouse → smooth. Relaunch → stutters. Switch the mouse to 1000 Hz → smooth.

Expected behavior

Dragging should stay smooth when no configured feature needs drag events.

Proposed fix: derive the tap's event mask from the configuration instead of always observing all drag events —

  • only include *MouseDragged for buttons that some scheme can actually observe while held: trigger buttons of buttons.mappings (including simultaneous / whileHeld), left+right when switchPrimaryButtonAndSecondaryButtons is on, back/forward for universalBackForward, and the autoScroll / gesture trigger buttons;
  • keep the existing rule for mouseMoved;
  • recreate the tap when the required set changes (this also means enabling autoScroll / gesture / redirectsToScroll starts observing mouseMoved without restarting the app).

I'm testing a patch along these lines locally and will follow up with results / a PR once verified.

Anything else?

Hardware: MacBook Pro 16" M4 Max, two 120 Hz displays, Keychron M6 8K (USB 0x3434:0xd049) in wired 8000 Hz mode.

Activity

  1. eret9616 commented on Sep 4, 2026

    @eret9616
    Author

    Update — tested the fix described above.

    Built v0.11.4 with the patch (drag events only observed for buttons a configured feature can use, tap recreated when the required set changes). Result on macOS 15.3.1 with the Keychron M6 8K still at 8000 Hz: window dragging is smooth with LinearMouse running, where the stock v0.11.4 stutters 100% of the time.

    CGGetEventTapList confirms what changed: LinearMouse's tap mask went from 0xe401cde to 0xe401c1e — leftMouseDragged and rightMouseDragged are no longer observed, while otherMouseDragged is still observed because my config maps buttons 2/3 on other devices. Scroll wheel, button down/up and key/flags events are unchanged.

    Happy to open a PR with the patch if that's welcome.

  2. kenneweg-airoa commented on Sep 18, 2026

    @kenneweg-airoa

    I am also seeing this on LinearMouse 0.11.4, running macOS 26.6.2 (25G83).

    At 1000 Hz, dragged windows lag about 2 seconds behind the pointer. Reducing the mouse polling rate to 500 Hz stops the lag for me.

  3. linked a pull request that will close this issueReduce CPU overhead from pointer motion events #1412on Oct 3, 2026
  4. lujjjh commented on Oct 3, 2026

    @lujjjh
    Collaborator

    Could you try v0.13.0-beta.1 and let me know if dragging feels smoother?

  5. added
    bug
    on Nov 4, 2026
  6. EdCarney commented on Nov 9, 2026

    @EdCarney

    Confirming v0.13.0-beta.6 fixes this for me.

    • macOS 26.6.2, Mac Studio
    • Corsair Slipstream gaming mouse + wireless receiver at 1000 Hz
    • My config only uses pointer acceleration and smooth scrolling

    On v0.12.0, click-and-drag lagged by several seconds and pointer movement stayed sluggish for a few seconds afterwards; quitting LinearMouse made it go away.

    On v0.13.0-beta.6 the dragging is smooth at 1000 Hz with LinearMouse running.

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

    bugwait for response

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions