FB12113281: sometimes event taps created with `CGEvent.tapCreate` stop receiving events
- Date: 2023-04-12
- Resolution: Open
- Area: Core Graphics API
- OS: macOS 13.4
- Type: Incorrect/Unexpected Behavior
Description
this is a tricky one. it's been reported by a couple of users of my apps. and it happened to me 3 times over 2.5 years. the last time i was able to confirm that it did not affect only my apps, but any app that is supposed to receive event taps, like Alfred. restarting the computer fixes the issue. but this still seems like a macOS bug overall.
Hi @godbout ! The same thing happened to me this week and it's been annoying.
Here is the pattern in my application:
- Register the events with
eventsOfInterest: .maxon launch - Open another huge application(Affinity Designer 2 in my case)
- Keep moving your mouse to trigger the callback
Then there is a chance that the application will never call the callback function registered in CGEvent.tapCreate anymore. Besides this, everything works fine.
@INCHMAN1900 do you mean that you're able to break the event tap whenever you want??? if yes that'd be great to let Apple know because this is a macOS bug. affects any app that use event taps, like Alfred (snippets) etc.
I've create a demo for this issue: CGEventTapCreateBugDemo.zip. It requires a clean launch of Chrome. If you've opened Chrome before, the issue may not appear, while Affinity Designer 2 always breaks the demo.
Things have been really weird these days. When I was creating this demo, I tried to remove the accessibility permission for it while it was running, and suddenly my mac froze, becoming unresponsive to any click/keyboard event. I've to restart the machine to get all back to work again.
so thanks to iTerm i was able to realize that this happens when a SecureInput is being locked up by Apple or a third party app. when it's Apple it's usually locked by a login window service. this bug should be fixed by Apple.