TCC is causing my mac to freeze for 5-20 seconds sporadically throughout the day. How can I fix it?

Sporadically throughout the day while I'm working on my 2017 27" iMac running macOS 10.14.6, the entire system will freeze for 5-20 seconds. There doesn't seem to be any rhyme or reason to it, but it does happen the most when utilizing apps that make use of Accessibility permissions, such as xGestures or BetterTouchTool. I later confirmed (as documented in this question) that the problem is TCC; the system WindowServer process is doing some kind of check to make sure a process has the permissions it needs, and it's getting locked up while doing so, causing the entire system to freeze until it finishes. During these times the cursor still moves, but I can't click anything on screen.

Does anyone have any idea what's going wrong here, or how I can fix it?

So far I've tried resetting the TCC database using the command tccutil reset All, and while that seemed to make my computer a little snappier at first, as soon as I granted all of the apps I use the permissions they require, the freezes came back. I've also reinstalled macOS from the recovery environment and that didn't fix it either.

I have a 2019 MacBook Pro running the same version of Mojave with much of the same software installed, and it does not have this issue, for what that's worth.

I've also read through this question but it's addressing a different TCC-related issue, and using an MDM profile will not help since its purpose is to add apps to the TCC database without requiring user intervention. This question is not about subsecond delays introduced by TCC when launching apps, but a show-stopping bug in TCC where it literally causes the entire mac to become unresponsive for several seconds.

Update 6/17/2021: one of the triggers for this bug appears to be apps that have an invalid or missing signature. I just managed to consistently trigger this bug in an app with an invalid signature where one of its child processes was trying to send Apple events. I then fixed it by resigning the app with my "Developer ID Application" certificate. I don't know at this point whether that specific kind of certificate is necessary.


I've discovered the problem is apps that are missing a signature, or have an invalid signature.

In these cases, whenever they try to access something that requires going through TCC, most of all using AppleScript or Apple events, the entire system will freeze while TCC churns away at... something. My best guess is that it's recalculating a signature for the app in question, and if the app's bundle is quite large, as is the case with some of the invalidly signed apps I was working with, it can take quite a long time. I've discovered that it's reproducible across all of my macOS 10.14 systems.

Why the system needs to freeze during this time is beyond me. That strikes me as some very, very bad design. Essentially the entire window server is blocking while waiting for TCC to finish its work. (See this earlier question of mine for how I discovered this is the case.)

The solution, more of a workaround really, is to resign the offending app. I've found that using a ad-hoc signature (i.e. codesign -f -s - /path/to/app.app) seems to work.