reports icon indicating copy to clipboard operation
reports copied to clipboard

FB12113281: sometimes event taps created with `CGEvent.tapCreate` stop receiving events

Open godbout opened this issue 2 years ago • 3 comments

  • 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.

godbout avatar Apr 12 '23 05:04 godbout

Hi @godbout ! The same thing happened to me this week and it's been annoying.

Here is the pattern in my application:

  1. Register the events with eventsOfInterest: .max on launch
  2. Open another huge application(Affinity Designer 2 in my case)
  3. 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 avatar Sep 04 '24 04:09 INCHMAN1900

@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.

godbout avatar Sep 04 '24 08:09 godbout

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.

INCHMAN1900 avatar Sep 04 '24 10:09 INCHMAN1900

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.

godbout avatar Dec 30 '24 04:12 godbout