Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS AppNap put into idle YARP applications in background #1153

Closed
francesco-romano opened this issue Mar 30, 2017 · 8 comments
Closed

macOS AppNap put into idle YARP applications in background #1153

francesco-romano opened this issue Mar 30, 2017 · 8 comments

Comments

@francesco-romano
Copy link
Collaborator

Starting from macOS Mavericks (10.9) macOS supports a new feature (AppNap) with the aim of improving energy efficiency and battery life on notebooks.

Unfortunately, it uses some heuristics to decide which app may be put into "nap" (i.e. in a very low scheduling priority), see official documentation here.

As a consequence some yarp applications (e.g. yarpdataplayer) at some point stops sending data to their ports.

As documented in Apple APIs, AppNap may be disabled using (unfortunately only) ObjectiveC calls in NSProcessInfo.

We have to test if this applies also to non UI applications, e.g. a simple main which in a run loop sends random data through an output port.

@vtikha
Copy link
Member

vtikha commented Mar 30, 2017

👍 @francesco-romano thanks for the details will look into it

@francesco-romano
Copy link
Collaborator Author

With @claudiofantacci we developed a simple macOS API wrapper to disable AppNap, see commit here: francesco-romano@4edc999

Of course this wrapper can be extended for other functions, but at the present state AppNap is the only "urgent" function to be implemented.

In this commit we applied the new API to disable AppNap on yarpdataplayer and the results are:

makas-pro:yarp makaveli$ pmset -g assertions
2017-03-30 10:40:52 +0200 
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 43394(yarpdataplayer): [0x0001e869000188a8] 00:23:54 PreventUserIdleSystemSleep named: "YARP requires AppNap off" 

so it is 24 minutes that yarpdataplayer streams data without stopping, and AppNap is not on as shown in the ActivityMonitor

screen shot 2017-03-30 at 10 42 02

We now have to find a "proper" and clean way to use this new API. Something like RAII (at least for the destruction part, I personally don't like to disable AppNap it in the constructor). Feedback is welcome

@francesco-romano
Copy link
Collaborator Author

ping (for everybody) to remember this issue

@drdanz
Copy link
Member

drdanz commented Aug 29, 2017

I don't think SystemInfo is the right place for the toggle function...

@claudiofantacci
Copy link
Collaborator

@drdanz where do you suggest this to go.

Please consider that for mac users this is a very important feature!

@drdanz
Copy link
Member

drdanz commented Aug 29, 2017

Not in a class that is named "something INFO" 😆
Perhaps Os.h?

@claudiofantacci
Copy link
Collaborator

🤣
That's fine. I'll speak with @francesco-romano asap 👍

@drdanz drdanz added Issue Type: Feat/Enh Req This issue requests some new feature or enhancement and removed PR Type: Feat/Enh This PR adds some new feature or enhances some part of YARP labels Mar 23, 2018
@drdanz
Copy link
Member

drdanz commented Mar 23, 2018

This was fixed in #1354 and it is available in YARP 2.3.72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment