

Ask HN: Strange Issue: Does Window Visibility Affect Performance on OS X? - polymathist

While writing some karma tests today for github.com&#x2F;soroushjp&#x2F;humble, I noticed something really strange. Sometimes the tests would take a long time to run (3-10s) and sometimes they would run in less than a second. After some experimentation I figured out how to consistently reproduce the results.<p>Watch this screen recording: http:&#x2F;&#x2F;recordit.co&#x2F;R30bQ3ZowE. I have three different browsers open and connected to Karma (Chrome, Safari, Firefox). When the browser windows are visible, the tests run in under a second. When I cover up the browser windows with another window, the tests take much much longer. Safari even disconnects because it was taking too long. I was really skeptical at first, but I repeated the test many times and always got the same results.<p>Am I right about my educated guess on what&#x27;s happening? Does OS X allocate more resources to windows that are visible?<p>FWIW this is on OS X 10.10.3, and I&#x27;m running the latest version of all browsers shown.
======
DiabloD3
From my experience with dealing with OSX, yes, OSX tries to optimize apps
(usually by force) by increasing the time their threads sleep depending on if
they have a window on screen or not.

It is part of their battery saving stuff.

~~~
benologist
Specifically it's "App Nap" -

[http://arstechnica.com/apple/2013/10/os-x-10-9/13/](http://arstechnica.com/apple/2013/10/os-x-10-9/13/)

