I developed a 32-bit application and I want to check if it is compatible with Mojave. According to this thread, I have to authorize my application to control my system in the Accessibility settings in order to use some functionality, which I did.
After I changed this setting, my app now takes around 5 minutes to start. Why? How can I reduce the lauching time without changing the Accessibility settings?
EDIT: I reproduce the problem with a 64-bits application on ElCapitain and Sierra (and I believe it also happens in High Sierra). Here is the procedure to reproduce it.
Create a C++ file like this one:
#include <iostream>
#include <ApplicationServices/ApplicationServices.h>
#define SIZE 1000000000
char dummy[SIZE] = {'a'};
int main()
{
if(AXIsProcessTrustedWithOptions(NULL))
std::cout << "Trusted" << std::endl;
else
std::cout << "Not trusted" << std::endl;
return 0;
}
I create a dummy
variable in order to increase the size of the binary. I noticed the problem is more notable with large application. Also AXIsProcessTrustedWithOptions
returns true
if the application is authorized to control the system.
Compile it:
clang++ -framework ApplicationServices repro.cpp -o repro
Create a bundle application and put repro
in MacOS directory:
repro.app
|_ Contents
|_ MacOS
|_ repro
Execute it for the first time:
$ date && open repro.app && date
Ven 10 mai 2019 16:58:10 CEST
Ven 10 mai 2019 16:58:10 CEST
As we can see, it takes less than a second to execute the application.
Now, add repro.app
in the list of trusted applications: System Preferences -> Security & Privacy -> Privacy tab -> Accessibility -> Add repro.app
in the list.
Run the app a second time:
$ date && open repro.app && date
Ven 10 mai 2019 17:06:31 CEST
Ven 10 mai 2019 17:06:36 CEST
This time, it takes more than 5 seconds to execute it.
It's relatively fast for this sample binary but the application I work on takes multiple minutes to start. Where is the issue?