Open Bug 931651 Opened 11 years ago Updated 2 years ago

[10.9] Investigate support for Mavericks' App Nap

Categories

(Core :: Widget: Cocoa, defect)

All
macOS
defect

Tracking

()

REOPENED

People

(Reporter: strugee, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [tpi:-][power])

OS X Mavericks supports a power-saving feature called App Nap[1], where the app goes to sleep if it is hidden by other things and not performing a specific action.

We should investigate supporting it.

 [1]: http://www.apple.com/osx/advanced-technologies/#appnap
If I'm reading this right, Mavericks uses App Nap for all apps by default. When you check "Get Info" on Firefox, "Prevent App Nap" is unchecked and will therefore be enabled.

We may, however, not have an equivalent of Safari's Power Saver feature which is summarized on the same App Nap page: "The new Safari Power Saver feature recognizes the difference between what you came to see and the stuff you probably didn’t. If the content is front and center it plays as usual. But if it’s off in the margins, Safari Power Saver pauses it. You’ll see a static preview, and it won’t run until you click to play it."
Yes, App Nap is enabled for all apps by default.  There are additional APIs that can be used to notify the OS of user-initiated background activities[1] if you need to prevent the OS from causing the app to sleep during those kinds of events.

As far as Safari's Power Nap, I would consider that separate from App Nap itself.  It doesn't appear to be related to an OS feature, but it's extra magic that Safari is doing with plugins, etc.

[1]: https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#//apple_ref/doc/uid/TP30000742-CH2-SW9
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to J. Ryan Stinnett [:jryans] from comment #2)
> Yes, App Nap is enabled for all apps by default.  There are additional APIs
> that can be used to notify the OS of user-initiated background activities[1]
> if you need to prevent the OS from causing the app to sleep during those
> kinds of events.

"user-initiated" might mean from Web content in our case, right? Since this is enabled by default for Firefox, I'd expect various websites to break due to JavaScript not running during App Nap, even though it was supposed to. If I'm not misunderstanding, determining when to call these additional APIs to prevent App Nap may be quite a challenge.
(In reply to Stephen Pohl [:spohl] from comment #3)
> "user-initiated" might mean from Web content in our case, right? Since this
> is enabled by default for Firefox, I'd expect various websites to break due
> to JavaScript not running during App Nap, even though it was supposed to. If
> I'm not misunderstanding, determining when to call these additional APIs to
> prevent App Nap may be quite a challenge.

It's a challenge indeed, but it may be worth looking into what we can do. I'm wondering how complicated it would be to wake up background scripts on a timer basis? And if that approach would break many web apps? Maybe that would bring enough gains without too much efforts? But that's just my guess at it...
For what it's worth, Firefox (FF 24 and today's mozilla-central nightly) does go into App Nap mode if you "hide" it (using the menu or Cmd-h).  You can see this in the Activity Monitor's Energy tab (under "Applications in last 8 hours).  It takes a long time (15-30 seconds) for an app's status to change in this panel after you've "hidden" it, even Safari.
Firefox (like Safari) also goes into App Nap mode if you switch to a different "desktop" (using Mission Control) -- one that contains no Firefox (or Safari) browser windows.
Both FF and Safari even go into App Nap mode if their browser windows are inactive for a while, even if they're still displayed on the same "desktop".
Firefox (Aurora) doesn't even show up for me in the Energy tab (and yes, it's running.) Earlybird does, and I see that it does enter App Nap correctly. What would cause an app to not even appear in this tab?
(In reply to Jon Baumgartner from comment #8)
> Firefox (Aurora) doesn't even show up for me in the Energy tab (and yes,
> it's running.) Earlybird does, and I see that it does enter App Nap
> correctly. What would cause an app to not even appear in this tab?

Firefox doesn't show up after a restart. See bug 931521.
So, should this bug be closed, or renamed to refer to Power Saver rather than App Nap?
Rereading my comments above, I don't think there's anything for us to do here.  So (at least provisionally) I'm going to close this bug WORKSFORME.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WORKSFORME
When only a single process is involved there shouldn't be anything to do. Has the multiple process case been tested to ensure that processes besides the UI process are also napped?
Thanks for the tip, Mark.  At some point I'll redo my tests with with a plugin (running in a second process) that doesn't change dynamically, and also with a content process (which is under development, but isn't yet on by default).

But I'm horribly busy, and wouldn't mind if someone else beat me to it.
Reopening for comment 12 so it doesn't fall off the radar.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Is there any way to measure the multiple process case to ensure that other processes beside the UI process are napping as well? I'd be willing to dig deeper into this.
Whiteboard: tpi:?
Whiteboard: tpi:? → [tpi:-][power]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.