Skip to content

fix(macos): drop key writes when DriverKit sink is disconnected#2013

Merged
jtroo merged 1 commit intojtroo:mainfrom
FlameFlag:flameflag/push-pzrqztlyyvpp
Apr 9, 2026
Merged

fix(macos): drop key writes when DriverKit sink is disconnected#2013
jtroo merged 1 commit intojtroo:mainfrom
FlameFlag:flameflag/push-pzrqztlyyvpp

Conversation

@FlameFlag
Copy link
Copy Markdown
Contributor

@FlameFlag FlameFlag commented Apr 8, 2026

Describe your changes. Use imperative present tense.

Closes #2008

After wake-from-sleep on macOS, the DriverKit virtual keyboard sink briefly disconnects

The event loop in src/kanata/macos.rs already recovers gracefully (release input, wait for output_ready, regrab), but the processing thread runs in parallel and can race ahead with a write before the event loop notices. That write returned NotConnected, which propagated through handle_keys as bail! and panicked the processing loop

Treat NotConnected from KbdOut::write_key / KbdOut::write_code as a non-fatal drop with a warning, mirroring the existing "log warn on sink disconnect" pattern used by event_loop. The event loop's output_ready() poll at the top of every iteration remains the authoritative recovery trigger

Checklist

  • Add documentation to docs/config.adoc
    • N/A
  • Add example and basic docs to cfg_samples/kanata.kbd
    • N/A
  • Update error messages
    • N/A
  • Added tests, or did manual testing
    • Yes, manual

Closes jtroo#2008

After wake-from-sleep on macOS, the DriverKit virtual keyboard sink
briefly disconnects

The event loop in src/kanata/macos.rs already recovers gracefully
(release input, wait for output_ready, regrab), but the processing
thread runs in parallel and can race ahead with a write before the event
loop notices. That write returned NotConnected, which propagated through
handle_keys as bail! and panicked the processing loop

Treat NotConnected from KbdOut::write_key / KbdOut::write_code as a
non-fatal drop with a warning, mirroring the existing "log warn on sink
disconnect" pattern used by event_loop. The event loop's output_ready()
poll at the top of every iteration remains the authoritative recovery
trigger
Copy link
Copy Markdown
Owner

@jtroo jtroo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtroo jtroo merged commit 0533c0e into jtroo:main Apr 9, 2026
5 checks passed
@FlameFlag FlameFlag deleted the flameflag/push-pzrqztlyyvpp branch April 9, 2026 06:03
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.

Bug: Kanata v1.12.0-prerelease-1 crashes on macOS after waking from sleep

2 participants