Disable App Nap in WebKitTestRunner UI process
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 17:44:55 +0000 (17:44 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 17:44:55 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144308

Reviewed by Daniel Bates.

* WebKitTestRunner/mac/main.mm:
(disableAppNapInUIProcess):
(main):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitTestRunner/mac/main.mm

index c5d4f2f..d4727cd 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-28  Alexey Proskuryakov  <ap@apple.com>
+
+        Disable App Nap in WebKitTestRunner UI process
+        https://bugs.webkit.org/show_bug.cgi?id=144308
+
+        Reviewed by Daniel Bates.
+
+        * WebKitTestRunner/mac/main.mm:
+        (disableAppNapInUIProcess):
+        (main):
+
 2015-04-28  Marcos Chavarría Teijeiro  <chavarria1991@gmail.com>
 
         [GTK] Update JHBuild Mesa download directory
index 2746b1a..a5efd57 100644 (file)
@@ -39,11 +39,19 @@ static void setDefaultsToConsistentValuesForTesting()
     [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:dict];
 }
 
+static void disableAppNapInUIProcess()
+{
+    NSActivityOptions options = (NSActivityUserInitiatedAllowingIdleSystemSleep | NSActivityLatencyCritical) & ~(NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled);
+    static id assertion = [[[NSProcessInfo processInfo] beginActivityWithOptions:options reason:@"WebKitTestRunner should not be subject to process suppression"] retain];
+    ASSERT_UNUSED(assertion, assertion);
+}
+
 int main(int argc, const char* argv[])
 {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     [NSApplication sharedApplication];
     setDefaultsToConsistentValuesForTesting();
+    disableAppNapInUIProcess(); // For secondary processes, app nap is disabled using WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled().
 
     {
         WTR::TestController controller(argc, argv);