Title: [193655] trunk/Source/WebKit2
Revision
193655
Author
barraclo...@apple.com
Date
2015-12-07 14:52:07 -0800 (Mon, 07 Dec 2015)

Log Message

UIProcess should determine AppNap state for WebPage
https://bugs.webkit.org/show_bug.cgi?id=151964

Reviewed by Anders Carlson.

Step 1 in unifying this with the iOS process suppression mechanism is to move the decision out of the WebContent process.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::dispatchViewStateChange):
(WebKit::WebPageProxy::setPageActivityState):
(WebKit::WebPageProxy::updateActivityToken):
(WebKit::WebPageProxy::preferencesDidChange):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isInWindow):
(WebKit::WebPageProxy::didUpdateViewState):
* UIProcess/WebPageProxy.messages.in:
    - WebPage now propagates PageActivityState to the WebPageProxy, for use
      determining the supression state of the WebProcess.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_shouldDispatchFakeMouseMoveEvents):
(WebKit::WebPage::setPageActivityState):
(WebKit::WebPage::setUserActivityStarted):
(WebKit::WebPage::setViewState):
(WebKit::WebPage::updatePreferences):
(WebKit::WebPage::updateUserActivity): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
    - WebPage no longer determines when to update it's own UserActivity - instead,
      let the UI process do so. As such, no longer need to track whether process
      supression is enabled. Instead, add message to

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (193654 => 193655)


--- trunk/Source/WebKit2/ChangeLog	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/ChangeLog	2015-12-07 22:52:07 UTC (rev 193655)
@@ -1,3 +1,37 @@
+2015-12-05  Gavin Barraclough  <barraclo...@apple.com>
+
+        UIProcess should determine AppNap state for WebPage
+        https://bugs.webkit.org/show_bug.cgi?id=151964
+
+        Reviewed by Anders Carlson.
+
+        Step 1 in unifying this with the iOS process suppression mechanism is to move the decision out of the WebContent process.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::dispatchViewStateChange):
+        (WebKit::WebPageProxy::setPageActivityState):
+        (WebKit::WebPageProxy::updateActivityToken):
+        (WebKit::WebPageProxy::preferencesDidChange):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::isInWindow):
+        (WebKit::WebPageProxy::didUpdateViewState):
+        * UIProcess/WebPageProxy.messages.in:
+            - WebPage now propagates PageActivityState to the WebPageProxy, for use
+              determining the supression state of the WebProcess.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_shouldDispatchFakeMouseMoveEvents):
+        (WebKit::WebPage::setPageActivityState):
+        (WebKit::WebPage::setUserActivityStarted):
+        (WebKit::WebPage::setViewState):
+        (WebKit::WebPage::updatePreferences):
+        (WebKit::WebPage::updateUserActivity): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+            - WebPage no longer determines when to update it's own UserActivity - instead,
+              let the UI process do so. As such, no longer need to track whether process
+              supression is enabled. Instead, add message to
+
 2015-12-07  Chris Dumez  <cdu...@apple.com>
 
         [WK2] Regression(r187691): If a page is showing an auth pane in one tab, any new tabs with same page hang until credentials are entered in first tab

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (193654 => 193655)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-12-07 22:52:07 UTC (rev 193655)
@@ -338,6 +338,8 @@
     , m_notificationPermissionRequestManager(*this)
     , m_userMediaPermissionRequestManager(*this)
     , m_viewState(ViewState::NoFlags)
+    , m_activityState(PageActivityState::NoFlags)
+    , m_userActivityStarted(false)
     , m_viewWasEverInWindow(false)
 #if PLATFORM(IOS)
     , m_alwaysRunsAtForegroundPriority(m_configuration->alwaysRunsAtForegroundPriority())
@@ -1448,6 +1450,15 @@
     m_viewWasEverInWindow |= isNowInWindow;
 }
 
+void WebPageProxy::setPageActivityState(PageActivityState::Flags activityState)
+{
+    if (m_activityState == activityState)
+        return;
+
+    m_activityState = activityState;
+    updateActivityToken();
+}
+
 void WebPageProxy::updateActivityToken()
 {
     if (m_viewState & ViewState::IsVisuallyIdle)
@@ -1455,6 +1466,14 @@
     else if (!m_pageIsUserObservableCount)
         m_pageIsUserObservableCount = m_process->processPool().userObservablePageCount();
 
+    // Start the activity to prevent AppNap if the page activity is in progress,
+    // the page is visible and non-idle, or process suppression is disabled.
+    bool shouldHoldUserActivity = m_activityState || !(m_viewState & ViewState::IsVisuallyIdle) || !m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
+    if (m_userActivityStarted != shouldHoldUserActivity) {
+        m_process->send(Messages::WebPage::SetUserActivityStarted(shouldHoldUserActivity), m_pageID);
+        m_userActivityStarted = shouldHoldUserActivity;
+    }
+
 #if PLATFORM(IOS)
     if (!isViewVisible() && !m_alwaysRunsAtForegroundPriority)
         m_activityToken = nullptr;
@@ -2732,6 +2751,7 @@
 #endif
 
     updateProccessSuppressionState();
+    updateActivityToken();
 
     m_pageClient.preferencesDidChange();
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (193654 => 193655)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-12-07 22:52:07 UTC (rev 193655)
@@ -420,6 +420,7 @@
     bool isInWindow() const { return m_viewState & WebCore::ViewState::IsInWindow; }
     void waitForDidUpdateViewState();
     void didUpdateViewState() { m_waitingForDidUpdateViewState = false; }
+    void setPageActivityState(WebCore::PageActivityState::Flags);
 
     void layerHostingModeDidChange();
 
@@ -1556,6 +1557,8 @@
     UserMediaPermissionRequestManagerProxy m_userMediaPermissionRequestManager;
 
     WebCore::ViewState::Flags m_viewState;
+    WebCore::PageActivityState::Flags m_activityState;
+    bool m_userActivityStarted;
     bool m_viewWasEverInWindow;
 #if PLATFORM(IOS)
     bool m_allowsMediaDocumentInlinePlayback { false };

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (193654 => 193655)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-12-07 22:52:07 UTC (rev 193655)
@@ -447,4 +447,6 @@
 #endif
 
     DidRestoreScrollPosition()
+
+    SetPageActivityState(unsigned activityState)
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (193654 => 193655)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-12-07 22:52:07 UTC (rev 193655)
@@ -341,7 +341,7 @@
     , m_scrollPinningBehavior(DoNotPin)
     , m_useAsyncScrolling(false)
     , m_viewState(parameters.viewState)
-    , m_processSuppressionEnabled(true)
+    , m_activityState(PageActivityState::NoFlags)
     , m_userActivity("Process suppression disabled for page.")
     , m_pendingNavigationID(0)
 #if ENABLE(WEBGL)
@@ -448,7 +448,6 @@
     m_page->setViewState(m_viewState);
     if (!isVisible())
         m_page->setIsPrerender();
-    updateUserActivity();
 
     updateIsInWindow(true);
 
@@ -534,18 +533,16 @@
 
 void WebPage::setPageActivityState(PageActivityState::Flags activityState)
 {
-    PageActivityState::Flags changed = m_activityState ^ activityState;
-    m_activityState = activityState;
+    if (m_activityState == activityState)
+        return;
 
-    if (changed)
-        updateUserActivity();
+    m_activityState = activityState;
+    send(Messages::WebPageProxy::SetPageActivityState(activityState));
 }
 
-void WebPage::updateUserActivity()
+void WebPage::setUserActivityStarted(bool started)
 {
-    // Start the activity to prevent AppNap if the page activity is in progress,
-    // the page is visible and non-idle, or process suppression is disabled.
-    if (m_activityState || !(m_viewState & ViewState::IsVisuallyIdle) || !m_processSuppressionEnabled)
+    if (started)
         m_userActivity.start();
     else
         m_userActivity.stop();
@@ -2371,9 +2368,6 @@
     ViewState::Flags changed = m_viewState ^ viewState;
     m_viewState = viewState;
 
-    if (changed)
-        updateUserActivity();
-
     m_page->setViewState(viewState);
     for (auto* pluginView : m_pluginViews)
         pluginView->viewStateDidChange(changed);
@@ -2931,12 +2925,6 @@
     settings.setServiceControlsEnabled(store.getBoolValueForKey(WebPreferencesKey::serviceControlsEnabledKey()));
 #endif
 
-    bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
-    if (m_processSuppressionEnabled != processSuppressionEnabled) {
-        m_processSuppressionEnabled = processSuppressionEnabled;
-        updateUserActivity();
-    }
-
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (193654 => 193655)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-12-07 22:52:07 UTC (rev 193655)
@@ -991,7 +991,7 @@
     void executeEditCommand(const String&, const String&);
     void setEditable(bool);
 
-    void updateUserActivity();
+    void setUserActivityStarted(bool);
 
     void mouseEvent(const WebMouseEvent&);
     void keyEvent(const WebKeyboardEvent&);
@@ -1394,7 +1394,6 @@
     WebCore::ViewState::Flags m_viewState;
     WebCore::PageActivityState::Flags m_activityState;
 
-    bool m_processSuppressionEnabled;
     UserActivity m_userActivity;
 
     uint64_t m_pendingNavigationID;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (193654 => 193655)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-12-07 22:44:33 UTC (rev 193654)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-12-07 22:52:07 UTC (rev 193655)
@@ -23,6 +23,7 @@
 messages -> WebPage LegacyReceiver {
     SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, uint64_t callbackID)
     SetViewState(unsigned viewState, bool wantsDidUpdateViewState, Vector<uint64_t> callbackIDs)
+    SetUserActivityStarted(bool started)
     SetLayerHostingMode(unsigned layerHostingMode)
 
     SetSessionID(WebCore::SessionID sessionID)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to