Timer delay with Yosemite


I have an issue with a Timer polling a serial port every second. Under Yosemite on a recent Mac Mini the timer will fire every second as expected, but when the screen saver turns on the Timer will fire randomly every 5, 9 or sometimes 20 seconds ! perfectly reproducible, and very surprising.

Is it the AppNap feature of Yosemite ? can’t find any mention of it anywhere. Is there a way to make my program respect it’s timers ?

Thank you for the help.

It sounds like the system putting a low priority on your app. You can check Activity Monitor to see if it’s AppNap.
Do you know if it’s just Yosemite or does this behavior present itself on 10.9 as well?
Is disabling the screen saver a viable workaround?

In Activity Monitor my app has a ‘No’ in the AppNap column, does it mean it is not ‘napping’ at that moment ? or that it does not respond to the AppNap feature ?

Disabling the screen saver is not viable on every machine, this is why I would like to avoid that. And it is a bit of a problem if the timers are not respected in Yosemite, I would have to review the whole design of the app.

The column shows whether the app is currently napping, so the No simply means that it’s not napping.

If the system is putting your app on low priority there’s really not much Xojo can do about it. Again, it’d be good to test to see if this is a Yosemite phenomena or if it occurs on 10.9 as well. It could be a (yet another) Yosemite issue. And I’m sure someone will pop by to be more helpful than me, so any information we can get will help them too.

of course there is somethign xojo can do about it :wink: You just have to register a time or interface intensive task is happening at that moment and the machine wont put you to sleep. You can do this through the MBS plugins or declares and probably other folks work on it as well. But it would be nice to have an application property perhaps to enable and disable app nap as our apps are doing things.

Far as I know, App nap is changed by a plist entry. I am unsure if you can turn it off and on instantly by changing the app’s plist setting for NSAppSleepDisabled.
On the other hand, have you tried a Xojo.Core.Timer with a lower tolerance?

Most likely, on Yosemite I have terrible trouble with Remote Debugger, unless it’s the front most application.

You may need to use NSProcessInfo to register that your application is doing some work.