Prewarmed WebContent processes never app nap
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2019 22:47:26 +0000 (22:47 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2019 22:47:26 +0000 (22:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197630

Reviewed by Geoffrey Garen.

Do not require actually having a WebPage in the WebContent process to App Nap.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateThrottleState):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index 8a7a5d1..fc45f24 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-06  Chris Dumez  <cdumez@apple.com>
+
+        Prewarmed WebContent processes never app nap
+        https://bugs.webkit.org/show_bug.cgi?id=197630
+
+        Reviewed by Geoffrey Garen.
+
+        Do not require actually having a WebPage in the WebContent process to App Nap.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updateThrottleState):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2019-05-06  Daniel Bates  <dabates@apple.com>
 
         Fix the build after r244975
index 0d8a0d3..affe24a 100644 (file)
@@ -766,15 +766,6 @@ void WebPage::updateThrottleState()
     bool isVisuallyIdle = m_activityState.contains(ActivityState::IsVisuallyIdle);
     bool pageSuppressed = m_processSuppressionEnabled && !isActive && isVisuallyIdle;
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    if (!pageSuppressed) {
-        // App nap must be manually enabled when not running the NSApplication run loop.
-        static std::once_flag onceKey;
-        std::call_once(onceKey, [] {
-            __CFRunLoopSetOptionsReason(__CFRunLoopOptionsEnableAppNap, CFSTR("Finished checkin as application - enable app nap"));
-        });
-    }
-#endif
     // The UserActivity keeps the processes runnable. So if the page should be suppressed, stop the activity.
     // If the page should not be supressed, start it.
     if (pageSuppressed)
index db33c10..29fd640 100644 (file)
@@ -199,6 +199,11 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& para
     [NSApplication _accessibilityInitialize];
 #endif
 
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    // App nap must be manually enabled when not running the NSApplication run loop.
+    __CFRunLoopSetOptionsReason(__CFRunLoopOptionsEnableAppNap, CFSTR("Finished checkin as application - enable app nap"));
+#endif
+
 #if TARGET_OS_IPHONE
     // Priority decay on iOS 9 is impacting page load time so we fix the priority of the WebProcess' main thread (rdar://problem/22003112).
     pthread_set_fixedpriority_self();