Posts

Post marked as solved
5 Replies
Right Again! detached a new thread to run the timer and now not seeing any latency from user actions. Much better stability overall on the timing accuracy.
Post marked as solved
5 Replies
Yes, I do keep the reference to the returned activity object. Indeed, your suggestion of using NSActivityBackground option solved the problem. using NSActivityUserInitiated also works and (as confirmed in ActivityMonitor) also makes the app prevent sleeping, so I don't have to disable sleep system wide.I found this document, which I think explains what was happening (the system was putting it in App Nap which, as stated, reduces timer firing frequency) https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/AppNap.html#//apple_ref/doc/uid/TP40013929-CH2-SW1I am still seeing some odd extra latency, for example, when choosing a menu item that opens a window I get a callback times in the range of ~0.8 - 1.1 seconds (the timer interval is 0.5 seconds). I can probably live with this, but it seems like it should do better. Weirdly, when the app is in the background it works BETTER- almost never throws a time over 0.6 seconds (I have it set to log a message if it is over this time). even when choosing menus in the other app, moving windows around, etc.
Post marked as solved
5 Replies
UPDATE: I found an error, which fixed part of the problem: My timers were in NSRunLoopDefaultMode. Putting them in NSRunLoopCommonModes seems to have fixed the latency problem with the screensaver active. However with display sleep active the latency still occurs (Added some diagnostic messages and am seeing time intervals from about 4 to about 20 seconds for a timer set to repeat every 0.5 seconds.