Skip to content

Upstream macOS resilience improvements to jtroo/kanata #19

Description

@malpern

Summary

Three macOS resilience improvements were added to keypath/bundled and should be proposed upstream to jtroo/kanata once validated in production.

Changes

  1. Port idle-clearing of stuck key states from Windows (c42d73a)

    • After 60s of no physical input, clears stuck keyberon normal-key states and PRESSED_KEYS
    • Mirrors the existing Windows LLHOOK clear_states_from_inactivity() mechanism
    • Addresses stuck keys caused by CPU pressure delaying release events
  2. Processing loop latency canary (52e61fc)

    • Logs [LATENCY] at info level when a processing iteration takes >20ms
    • Always active, no allocation on the fast path, not platform-gated
    • Aids post-hoc diagnosis of stuck key incidents
  3. Latency-triggered soft reset (85330a1)

    • After 5 consecutive slow iterations (>20ms each), clears all stuck key states
    • Releases keyberon states, PRESSED_KEYS, and tracked output keys
    • Does NOT release/regrab the HID device (no disruptive keyboard dropout)
    • macOS-only

Context

On macOS, CPU/memory pressure (compilation, Spotlight indexing) can starve the processing thread, delaying release events and leaving keys stuck. Windows already has idle-clearing for similar scenarios (Win+L lock screen). These changes extend that resilience to macOS.

Before upstreaming

  • Validate in KeyPath production use (no false positives from soft reset)
  • Confirm latency canary logging is not too noisy at 20ms threshold
  • Consider making the soft reset threshold configurable via defcfg
  • Open PR against jtroo/kanata with appropriate upstream commit messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions