Application Nap ?

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi all,

I have made an application that is scanning for bluetooth beacons.
Once one is found is is with X meters, it will trigger an script to check authentication of this device.
(This is security related application, to prevent unauthorised devices to leave the building)

Now the thing is, sometimes it looks like the app is sleeping, and when I move the mouse it will start working straight away.
Even when the display is not sleeping yet.

Anyone have any advice for me ?
Thanks!
 

TheBSDGuy

macrumors 6502
Jan 24, 2012
317
29
Welcome to the world of App Nap. App Nap is a "feature" implemented that's supposed to save energy. What it does is put applications to sleep, without warning, without the user knowing about it. It's probably the worst implementation of an idea I've ever seen. If you go to the Apple App Store and read some of the comments about Yosemite, a lot of them state stuff like "it took 24 hours to download." My guess is that App Nap has put their application to sleep while downloading. Apple should have put a warning up before allowing an application to enter App Nap and give people options to either allow it to occur or disable it for a given application. They didn't, and it confuses a lot of people.

Here are your options:

1. Tell users to open up the "info" panel for it and check the "disable App Nap" option.

2. Hard code it into your installation to ignore app nap. See the developer documentation for that.

3. Disable App Nap system wide. You'll need to do a Google or Bing search on it but it's easily done via command line.

I don't know that I think that it's a bad idea, but the implementation is horrible. Been there, done that.

Good luck and don't worry. I suspect you can fix it.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Apple should have put a warning up before allowing an application to enter App Nap and give people options to either allow it to occur or disable it for a given application. They didn't, and it confuses a lot of people.
Yeah there is nothing that can't be fixed with a pop-up window. :rolleyes: Seriously though, an application that does active work, such as downloading a file shouldn't go to sleep. I'm not sure what is different with App Nap and previously inactive applications which always reported as sleeping in top for example. In that state they use up no CPU resources and can even be paged to a VM backing store if there is a need I believe.
 

Ritsuka

macrumors 6502a
Sep 3, 2006
888
370
Check the api to tell the system you are running an background operation. It's the application duty to tell the system it doesn't want to be suspended.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Check the api to tell the system you are running an background operation. It's the application duty to tell the system it doesn't want to be suspended.
Odd, should we also use yields to get CPU time? If an application has been registered with launchd to run in the background the system should already know it's a background process and when it's suppose to run.
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Welcome to the world of App Nap. App Nap is a "feature" implemented that's supposed to save energy. What it does is put applications to sleep, without warning, without the user knowing about it. It's probably the worst implementation of an idea I've ever seen. If you go to the Apple App Store and read some of the comments about Yosemite, a lot of them state stuff like "it took 24 hours to download." My guess is that App Nap has put their application to sleep while downloading. Apple should have put a warning up before allowing an application to enter App Nap and give people options to either allow it to occur or disable it for a given application. They didn't, and it confuses a lot of people.

Here are your options:

1. Tell users to open up the "info" panel for it and check the "disable App Nap" option.

2. Hard code it into your installation to ignore app nap. See the developer documentation for that.

3. Disable App Nap system wide. You'll need to do a Google or Bing search on it but it's easily done via command line.

I don't know that I think that it's a bad idea, but the implementation is horrible. Been there, done that.

Good luck and don't worry. I suspect you can fix it.
I'm gonna try option 3. Since option 1 is not an option.
Not because I don't want the users to do it, but because they can't.
For some reason the whole tickbox for 'Prevent App Nap' does not show up for my app executable.
Code:
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
Just gonna throw it in the app to run it as root ;-)

I couldn't find anything clear enough for option 2.
Any advice ? Or link would be appriciated :)

It's an gui application, the user is able to choose an minimum distance for starting the authentication of the device to be taken out of the building and by who. It's a kind of middle-ware for a FileMaker database.
Wireless authentication <3
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands