orta / GIFs

A Mac App for finding GIFs
Other
602 stars 39 forks source link

App uses excessive CPU/energy while inactive #54

Open lazerwalker opened 8 years ago

lazerwalker commented 8 years ago

On my 12" MacBook, this regularly takes up > 30% of my CPU usage, and gets a spot in the vilified "apps using significant energy" list, even when it's not actively visible on-screen and merely open.

I assume there's only so much that can be done about performance when actively being used – makes sense when rendering a few dozen large-ish gifs at once – but this shouldn't need to do anything while not visible on-screen.

I'm not familiar enough with OS X dev to know what the proper solution is (is it just a matter of responding to the right app delegate lifecycle methods and pausing active gif animation while not active? Is App Nap a thing third-party devs can implement?) but happy to help out with some dev time if it'd be helpful.

orta commented 8 years ago

Hrm, two places I could see easy wins:

orta commented 8 years ago

https://developer.apple.com/library/prerelease/mac/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/WorkWhenActive.html#//apple_ref/doc/uid/TP40013929-CH17-SW1

- (void)applicationWillResignActive:(NSNotification *)aNotification {
   // Prepare to halt operations, animations, and UI updates
}

and

- (void)applicationWillBecomeActive:(NSNotification *)aNotification {
   // Prepare to resume operations, animations, and UI updates
}

or the window occlusion API - https://developer.apple.com/library/prerelease/mac/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/WorkWhenVisible.html#//apple_ref/doc/uid/TP40013929-CH18-SW1

orta commented 8 years ago

There may also be a JS api for starting/stopping GIFs in WebKit