Title: [161301] trunk/Source/WebKit2
Revision
161301
Author
[email protected]
Date
2014-01-03 17:57:46 -0800 (Fri, 03 Jan 2014)

Log Message

Simplify process suppression state calculation
https://bugs.webkit.org/show_bug.cgi?id=126473

Reviewed by Geoffrey Garen & Sam Weinig.

Don't check the application occlusion state (this is covered by the pages already),
and let the page check visually idle. Remove layers of functions.

* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didFinishLaunching):
    - Let the network process nap if all processes in its context are napping.*
      (* Except not really. We currently leak a boost onto the process anyway.)
* UIProcess/Plugins/PluginProcessProxy.cpp:
(WebKit::PluginProcessProxy::didFinishLaunching):
    - Let the plugin process nap if all processes in all contexts are napping.
* UIProcess/WebContext.h:
    - Remove canEnableProcessSuppressionForNetworkProcess & canEnableProcessSuppressionForWebProcess
    - canEnableProcessSuppressionForGlobalChildProcesses -> processSuppressionIsEnabledForAllContexts
    - combine updateProcessSuppressionStateOfChildProcesses & updateProcessSuppressionStateOfGlobalChildProcesses
        -> updateProcessSuppressionState
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::isProcessSuppressible):
    - WebProcess is supressible if IsVisuallyIdle.
(WebKit::WebPageProxy::viewStateDidChange):
    - WebProcessProxy should updateProcessSuppressionState when IsVisuallyIdle changes.
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createWebPage):
(WebKit::WebProcessProxy::addExistingWebPage):
(WebKit::WebProcessProxy::pageSuppressibilityChanged):
(WebKit::WebProcessProxy::pagePreferencesChanged):
    - pageIsProcessSuppressible -> isProcessSuppressible
* UIProcess/WebProcessProxy.h:
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::updateProcessSuppressionState):
    - Update supression state of network & plugin processes.
(WebKit::WebContext::processSuppressionIsEnabledForAllContexts):
    - Changed iterator style, made a static member of WebContext.
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::updateProcessSuppressionState):
    - Ask the WebContext to update supression state.
* UIProcess/mac/WindowServerConnection.h:
* UIProcess/mac/WindowServerConnection.mm:
(WebKit::WindowServerConnection::windowServerConnectionStateChanged):
(WebKit::WindowServerConnection::WindowServerConnection):
    - Remove application occlusion state.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (161300 => 161301)


--- trunk/Source/WebKit2/ChangeLog	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/ChangeLog	2014-01-04 01:57:46 UTC (rev 161301)
@@ -1,3 +1,52 @@
+2014-01-03  Gavin Barraclough  <[email protected]>
+
+        Simplify process suppression state calculation
+        https://bugs.webkit.org/show_bug.cgi?id=126473
+
+        Reviewed by Geoffrey Garen & Sam Weinig.
+
+        Don't check the application occlusion state (this is covered by the pages already),
+        and let the page check visually idle. Remove layers of functions.
+
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didFinishLaunching):
+            - Let the network process nap if all processes in its context are napping.*
+              (* Except not really. We currently leak a boost onto the process anyway.)
+        * UIProcess/Plugins/PluginProcessProxy.cpp:
+        (WebKit::PluginProcessProxy::didFinishLaunching):
+            - Let the plugin process nap if all processes in all contexts are napping.
+        * UIProcess/WebContext.h:
+            - Remove canEnableProcessSuppressionForNetworkProcess & canEnableProcessSuppressionForWebProcess
+            - canEnableProcessSuppressionForGlobalChildProcesses -> processSuppressionIsEnabledForAllContexts
+            - combine updateProcessSuppressionStateOfChildProcesses & updateProcessSuppressionStateOfGlobalChildProcesses
+                -> updateProcessSuppressionState
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::isProcessSuppressible):
+            - WebProcess is supressible if IsVisuallyIdle.
+        (WebKit::WebPageProxy::viewStateDidChange):
+            - WebProcessProxy should updateProcessSuppressionState when IsVisuallyIdle changes.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::createWebPage):
+        (WebKit::WebProcessProxy::addExistingWebPage):
+        (WebKit::WebProcessProxy::pageSuppressibilityChanged):
+        (WebKit::WebProcessProxy::pagePreferencesChanged):
+            - pageIsProcessSuppressible -> isProcessSuppressible
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::updateProcessSuppressionState):
+            - Update supression state of network & plugin processes.
+        (WebKit::WebContext::processSuppressionIsEnabledForAllContexts):
+            - Changed iterator style, made a static member of WebContext.
+        * UIProcess/mac/WebProcessProxyMac.mm:
+        (WebKit::WebProcessProxy::updateProcessSuppressionState):
+            - Ask the WebContext to update supression state.
+        * UIProcess/mac/WindowServerConnection.h:
+        * UIProcess/mac/WindowServerConnection.mm:
+        (WebKit::WindowServerConnection::windowServerConnectionStateChanged):
+        (WebKit::WindowServerConnection::WindowServerConnection):
+            - Remove application occlusion state.
+
 2014-01-03  Tim Horton  <[email protected]>
 
         [iOS] [WK2] TileController creates all tiles on first paint, making it slow and consuming lots of memory

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2014-01-04 01:57:46 UTC (rev 161301)
@@ -194,7 +194,7 @@
     m_numPendingConnectionRequests = 0;
 
 #if PLATFORM(MAC)
-    if (m_webContext.canEnableProcessSuppressionForNetworkProcess())
+    if (m_webContext.processSuppressionEnabled())
         setProcessSuppressionEnabled(true);
 #endif
 }

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2014-01-04 01:57:46 UTC (rev 161301)
@@ -225,7 +225,7 @@
     m_numPendingConnectionRequests = 0;
 
 #if PLATFORM(MAC)
-    if (WebContext::canEnableProcessSuppressionForGlobalChildProcesses())
+    if (WebContext::processSuppressionIsEnabledForAllContexts())
         setProcessSuppressionEnabled(true);
 #endif
 }

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2014-01-04 01:57:46 UTC (rev 161301)
@@ -284,10 +284,7 @@
 
 #if PLATFORM(MAC)
     bool processSuppressionEnabled() const;
-    bool canEnableProcessSuppressionForNetworkProcess() const;
-    bool canEnableProcessSuppressionForWebProcess(const WebProcessProxy*) const;
-    static bool canEnableProcessSuppressionForGlobalChildProcesses();
-    void updateProcessSuppressionStateOfChildProcesses();
+    static bool processSuppressionIsEnabledForAllContexts();
 #endif
 
     void windowServerConnectionStateChanged();
@@ -318,7 +315,7 @@
 #endif
 
 #if PLATFORM(MAC)
-    static void updateProcessSuppressionStateOfGlobalChildProcesses();
+    void updateProcessSuppressionState() const;
 #endif
 
 private:

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-01-04 01:57:46 UTC (rev 161301)
@@ -515,6 +515,11 @@
 #endif
 }
 
+bool WebPageProxy::isProcessSuppressible() const
+{
+    return (m_viewState & ViewState::IsVisuallyIdle) && m_pageGroup->preferences()->pageVisibilityBasedProcessSuppressionEnabled();
+}
+
 void WebPageProxy::close()
 {
     if (!isValid())
@@ -958,9 +963,10 @@
     if (changed)
         m_process->send(Messages::WebPage::SetViewState(m_viewState, wantsReply == WantsReplyOrNot::DoesWantReply), m_pageID);
 
+    if (changed & ViewState::IsVisuallyIdle)
+        m_process->pageSuppressibilityChanged(this);
+
     if (changed & ViewState::IsVisible) {
-        m_process->pageVisibilityChanged(this);
-
         if (!isViewVisible()) {
             // If we've started the responsiveness timer as part of telling the web process to update the backing store
             // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-01-04 01:57:46 UTC (rev 161301)
@@ -425,6 +425,7 @@
     WebCore::IntSize viewSize() const;
     bool isViewVisible() const { return m_viewState & ViewState::IsVisible; }
     bool isViewWindowActive() const;
+    bool isProcessSuppressible() const;
 
     void executeEditCommand(const String& commandName);
     void validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback>);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-01-04 01:57:46 UTC (rev 161301)
@@ -170,7 +170,7 @@
     m_pageMap.set(pageID, webPage.get());
     globalPageMap().set(pageID, webPage.get());
 #if PLATFORM(MAC)
-    if (pageIsProcessSuppressible(webPage.get()))
+    if (webPage->isProcessSuppressible())
         m_processSuppressiblePages.add(pageID);
     updateProcessSuppressionState();
 #endif
@@ -182,7 +182,7 @@
     m_pageMap.set(pageID, webPage);
     globalPageMap().set(pageID, webPage);
 #if PLATFORM(MAC)
-    if (pageIsProcessSuppressible(webPage))
+    if (webPage->isProcessSuppressible())
         m_processSuppressiblePages.add(pageID);
     updateProcessSuppressionState();
 #endif
@@ -601,10 +601,10 @@
     m_context->historyClient().didUpdateHistoryTitle(&m_context.get(), page, title, url, frame);
 }
 
-void WebProcessProxy::pageVisibilityChanged(WebKit::WebPageProxy *page)
+void WebProcessProxy::pageSuppressibilityChanged(WebKit::WebPageProxy *page)
 {
 #if PLATFORM(MAC)
-    if (pageIsProcessSuppressible(page))
+    if (page->isProcessSuppressible())
         m_processSuppressiblePages.add(page->pageID());
     else
         m_processSuppressiblePages.remove(page->pageID());
@@ -617,7 +617,7 @@
 void WebProcessProxy::pagePreferencesChanged(WebKit::WebPageProxy *page)
 {
 #if PLATFORM(MAC)
-    if (pageIsProcessSuppressible(page))
+    if (page->isProcessSuppressible())
         m_processSuppressiblePages.add(page->pageID());
     else
         m_processSuppressiblePages.remove(page->pageID());

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2014-01-04 01:57:46 UTC (rev 161301)
@@ -106,7 +106,7 @@
 
     DownloadProxy* createDownloadProxy();
 
-    void pageVisibilityChanged(WebPageProxy*);
+    void pageSuppressibilityChanged(WebPageProxy*);
     void pagePreferencesChanged(WebPageProxy*);
 
     void didSaveToPageCache();
@@ -114,7 +114,6 @@
 
 #if PLATFORM(MAC)
     bool allPagesAreProcessSuppressible() const;
-    static bool pageIsProcessSuppressible(WebPageProxy*);
     void updateProcessSuppressionState();
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-01-04 01:57:46 UTC (rev 161301)
@@ -101,31 +101,17 @@
     [[NSUserDefaults standardUserDefaults] registerDefaults:registrationDictionary];
 }
 
-void WebContext::updateProcessSuppressionStateOfGlobalChildProcesses()
+void WebContext::updateProcessSuppressionState() const
 {
-    // The plan is to have all child processes become context specific.  This function
-    // can be removed once that is complete.
-#if ENABLE(NETSCAPE_PLUGIN_API) || ENABLE(SHARED_WORKER_PROCESS)
-    bool canEnable = WebContext::canEnableProcessSuppressionForGlobalChildProcesses();
+#if ENABLE(NETWORK_PROCESS)
+    if (m_usesNetworkProcess && m_networkProcess)
+        m_networkProcess->setProcessSuppressionEnabled(processSuppressionEnabled());
 #endif
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    PluginProcessManager::shared().setProcessSuppressionEnabled(canEnable);
+    PluginProcessManager::shared().setProcessSuppressionEnabled(processSuppressionIsEnabledForAllContexts());
 #endif
 }
 
-static bool processSuppressionIsEnabledForAllContexts()
-{
-    bool result = true;
-    const Vector<WebContext*>& contexts = WebContext::allContexts();
-    for (size_t i = 0, count = contexts.size(); i < count; ++i) {
-        if (!contexts[i]->processSuppressionEnabled()) {
-            result = false;
-            break;
-        }
-    }
-    return result;
-}
-
 void WebContext::platformInitialize()
 {
     registerUserDefaultsIfNeeded();
@@ -400,35 +386,15 @@
     return true;
 }
 
-void WebContext::updateProcessSuppressionStateOfChildProcesses()
+bool WebContext::processSuppressionIsEnabledForAllContexts()
 {
-#if ENABLE(NETWORK_PROCESS)
-    bool canEnable = canEnableProcessSuppressionForNetworkProcess();
-    if (usesNetworkProcess() && networkProcess())
-        networkProcess()->setProcessSuppressionEnabled(canEnable);
-#endif
-    size_t processCount = m_processes.size();
-    for (size_t i = 0; i < processCount; ++i) {
-        WebProcessProxy* process = m_processes[i].get();
-        process->updateProcessSuppressionState();
+    for (const auto* context : WebContext::allContexts()) {
+        if (!context->processSuppressionEnabled())
+            return false;
     }
+    return true;
 }
 
-bool WebContext::canEnableProcessSuppressionForNetworkProcess() const
-{
-    return (WindowServerConnection::shared().applicationIsOccluded() || WindowServerConnection::shared().applicationWindowModificationsHaveStopped()) && processSuppressionEnabled();
-}
-
-bool WebContext::canEnableProcessSuppressionForWebProcess(const WebKit::WebProcessProxy *webProcess) const
-{
-    return WindowServerConnection::shared().applicationIsOccluded() || WindowServerConnection::shared().applicationWindowModificationsHaveStopped() || webProcess->allPagesAreProcessSuppressible();
-}
-
-bool WebContext::canEnableProcessSuppressionForGlobalChildProcesses()
-{
-    return (WindowServerConnection::shared().applicationIsOccluded() || WindowServerConnection::shared().applicationWindowModificationsHaveStopped()) && processSuppressionIsEnabledForAllContexts();
-}
-
 void WebContext::registerNotificationObservers()
 {
 #if !PLATFORM(IOS)

Modified: trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm	2014-01-04 01:57:46 UTC (rev 161301)
@@ -59,11 +59,6 @@
     launchOptions.useXPC = shouldUseXPC();
 }
 
-bool WebProcessProxy::pageIsProcessSuppressible(WebPageProxy* page)
-{
-    return !page->isViewVisible() && page->pageGroup().preferences()->pageVisibilityBasedProcessSuppressionEnabled();
-}
-
 bool WebProcessProxy::allPagesAreProcessSuppressible() const
 {
     return (m_processSuppressiblePages.size() == m_pageMap.size()) && !m_processSuppressiblePages.isEmpty();
@@ -74,12 +69,14 @@
     if (!isValid())
         return;
 
-    bool canEnable = m_context->canEnableProcessSuppressionForWebProcess(this);
+    bool canEnable = allPagesAreProcessSuppressible();
     if (m_processSuppressionEnabled == canEnable)
         return;
     m_processSuppressionEnabled = canEnable;
 
     connection()->send(Messages::WebProcess::SetProcessSuppressionEnabled(m_processSuppressionEnabled), 0);
+
+    m_context->updateProcessSuppressionState();
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.h (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.h	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.h	2014-01-04 01:57:46 UTC (rev 161301)
@@ -32,7 +32,6 @@
 public:
     static WindowServerConnection& shared();
 
-    bool applicationIsOccluded() const { return m_applicationIsOccluded; }
     bool applicationWindowModificationsHaveStopped() const { return m_applicationWindowModificationsHaveStopped; }
 
 private:
@@ -41,16 +40,12 @@
 #if HAVE(WINDOW_SERVER_OCCLUSION_NOTIFICATIONS)
     void windowServerConnectionStateChanged();
 
-    void applicationBecameOccluded(bool occluded);
     void applicationWindowModificationsStopped(bool stopped);
 
-    static void applicationBecameVisible(uint32_t, void*, uint32_t, void*, uint32_t);
-    static void applicationBecameOccluded(uint32_t, void*, uint32_t, void*, uint32_t);
     static void applicationWindowModificationsStarted(uint32_t, void*, uint32_t, void*, uint32_t);
     static void applicationWindowModificationsStopped(uint32_t, void*, uint32_t, void*, uint32_t);
 #endif
 
-    bool m_applicationIsOccluded;
     bool m_applicationWindowModificationsHaveStopped;
 };
 

Modified: trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.mm (161300 => 161301)


--- trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.mm	2014-01-04 01:27:01 UTC (rev 161300)
+++ trunk/Source/WebKit2/UIProcess/mac/WindowServerConnection.mm	2014-01-04 01:57:46 UTC (rev 161301)
@@ -33,14 +33,6 @@
 
 #if HAVE(WINDOW_SERVER_OCCLUSION_NOTIFICATIONS)
 
-void WindowServerConnection::applicationBecameOccluded(bool occluded)
-{
-    if (m_applicationIsOccluded == occluded)
-        return;
-    m_applicationIsOccluded = occluded;
-    windowServerConnectionStateChanged();
-}
-
 void WindowServerConnection::applicationWindowModificationsStopped(bool stopped)
 {
     if (m_applicationWindowModificationsHaveStopped == stopped)
@@ -49,16 +41,6 @@
     windowServerConnectionStateChanged();
 }
 
-void WindowServerConnection::applicationBecameVisible(uint32_t, void*, uint32_t, void*, uint32_t)
-{
-    WindowServerConnection::shared().applicationBecameOccluded(false);
-}
-
-void WindowServerConnection::applicationBecameOccluded(uint32_t, void*, uint32_t, void*, uint32_t)
-{
-    WindowServerConnection::shared().applicationBecameOccluded(true);
-}
-
 void WindowServerConnection::applicationWindowModificationsStarted(uint32_t, void*, uint32_t, void*, uint32_t)
 {
     WindowServerConnection::shared().applicationWindowModificationsStopped(false);
@@ -71,13 +53,8 @@
 
 void WindowServerConnection::windowServerConnectionStateChanged()
 {
-    for (auto* context : WebContext::allContexts()) {
+    for (auto* context : WebContext::allContexts())
         context->windowServerConnectionStateChanged();
-        if (context->processSuppressionEnabled())
-            context->updateProcessSuppressionStateOfChildProcesses();
-    }
-
-    WebContext::updateProcessSuppressionStateOfGlobalChildProcesses();
 }
 
 #endif
@@ -89,8 +66,7 @@
 }
 
 WindowServerConnection::WindowServerConnection()
-    : m_applicationIsOccluded(false)
-    , m_applicationWindowModificationsHaveStopped(false)
+    : m_applicationWindowModificationsHaveStopped(false)
 {
 #if HAVE(WINDOW_SERVER_OCCLUSION_NOTIFICATIONS)
     struct OcclusionNotificationHandler {
@@ -100,8 +76,6 @@
     };
 
     static const OcclusionNotificationHandler occlusionNotificationHandlers[] = {
-        { WKOcclusionNotificationTypeApplicationBecameVisible, applicationBecameVisible, "Application Became Visible" },
-        { WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded, "Application Became Occluded" },
         { WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted, "Application Window Modifications Started" },
         { WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped, "Application Window Modifications Stopped" },
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to