Open dpogue opened 1 month ago
Was NSProcessInfo beginActivityWithOptions:reason: considered as an alternative? https://developer.apple.com/documentation/foundation/nsprocessinfo/1415995-beginactivitywithoptions
Implementing beginActivityWithOptions:reason: has been on my list of things to do because I also feel like the app is less responsive when it's not in the foreground, which may reflect something like not passing a NSActivityUserInitiated or NSActivityBackground flag.
Was NSProcessInfo beginActivityWithOptions:reason: considered as an alternative?
I did not know that existed... all my investigation led to the IOKit API, which is also what's used internally by the caffeinate
command-line tool.
One advantage of the IOKit code (besides it being C API and not ObjC 😛) is that it works back to OS X 10.5, whereas the NSProcessInfo code looks to be 10.7 and up only.
Do you know if there's an actual difference in implementation between the two, or does NSProcessInfo just call out to IOKit?
beginActivity: seems to require 10.9 - which would be even higher. But - beginActivity also controls our QoS level in the operating system, which the IOKit call does not do. The reason I've been suspicious we might need this call is that our login window will not appear until the app is brought to the foreground - which could imply our run loop is getting squashed.
Application/backgrounding QoS was not introduced until later. Very possibly that release was 10.9. So the IOKit call would not cover that.
It's a bit of a mess, but:
FWIW - I'd prefer if there was a compile path that did not include IOKit at all for later builds. It's not critical - but IOKit has bit by bit been getting deprecated or restricted. So it would be preferable if the modern builds didn't link IOKit just to reduce risk. Could just be that I'm overly cautious on IOKit use - but again, been seeing a lot of IOKit API getting deprecated.
Closes #1600