- Revision
- 207424
- Author
- barraclo...@apple.com
- Date
- 2016-10-17 13:18:38 -0700 (Mon, 17 Oct 2016)
Log Message
UIProcess should determine throttle state for WebContent process
https://bugs.webkit.org/show_bug.cgi?id=163556
Reviewed by Anders Carlsson.
This is a step towards merging page/process throttling code for mac & iOS.
Previously WebPage determined whether to start a UserActivity based on page activity,
visibility and the preference to disable. Now WebPage passes the activity state across
to WebPageProxy, which makes the decision & explicitly instructs WebPage to start/stop
the UserActivity.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
- updateActivityToken + updateProccessSuppressionState -> updateThrottleState
(WebKit::WebPageProxy::reattachToWebProcess):
- updateActivityToken -> updateThrottleState
(WebKit::WebPageProxy::dispatchViewStateChange):
- updateActivityToken -> updateThrottleState
(WebKit::WebPageProxy::setPageActivityState):
- Record activity state passed from WebPage, and update.
(WebKit::WebPageProxy::preferencesDidChange):
- updateProccessSuppressionState -> updateThrottleState
(WebKit::WebPageProxy::updateActivityToken): Deleted.
(WebKit::WebPageProxy::updateProccessSuppressionState): Deleted.
(WebKit::WebPageProxy::updateThrottleState):
- Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
- Compute whether page should be suppressed, and send SetPageSuppressed message accordingly.
* UIProcess/WebPageProxy.h:
- Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
- Added setPageActivityState/m_activityState to report/record page activity.
- Added m_pageSuppressed to prevent redundant message sends.
* UIProcess/WebPageProxy.messages.in:
- Expose SetPageActivityState message (called by WebPage).
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
- removed m_processSuppressionEnabled
- updateUserActivity -> setPageSuppressed - explicitly set the page to not be suppressed, until WebPageProxy tells us to do so.
(WebKit::WebPage::setPageActivityState):
- post activity state on to WebPageProxy.
(WebKit::WebPage::setPageSuppressed):
- Start/stop USerActivity accordingly.
(WebKit::WebPage::setViewState):
- No longer need to monitor ViewState changes on the WebProcess side.
(WebKit::WebPage::updatePreferences):
- No longer need to monitor preference changes on the WebProcess side.
(WebKit::WebPage::updateUserActivity): Deleted.
- Only updated on reciept of setPageSuppressed message.
* WebProcess/WebPage/WebPage.h:
- Removed m_activityState, m_processSuppressionEnabled, updateUserActivity.
- Added setPageSuppressed message.
* WebProcess/WebPage/WebPage.messages.in:
- Added SetPageSuppressed message.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (207423 => 207424)
--- trunk/Source/WebKit2/ChangeLog 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-17 20:18:38 UTC (rev 207424)
@@ -1,3 +1,59 @@
+2016-10-17 Gavin Barraclough <barraclo...@apple.com>
+
+ UIProcess should determine throttle state for WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=163556
+
+ Reviewed by Anders Carlsson.
+
+ This is a step towards merging page/process throttling code for mac & iOS.
+
+ Previously WebPage determined whether to start a UserActivity based on page activity,
+ visibility and the preference to disable. Now WebPage passes the activity state across
+ to WebPageProxy, which makes the decision & explicitly instructs WebPage to start/stop
+ the UserActivity.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ - updateActivityToken + updateProccessSuppressionState -> updateThrottleState
+ (WebKit::WebPageProxy::reattachToWebProcess):
+ - updateActivityToken -> updateThrottleState
+ (WebKit::WebPageProxy::dispatchViewStateChange):
+ - updateActivityToken -> updateThrottleState
+ (WebKit::WebPageProxy::setPageActivityState):
+ - Record activity state passed from WebPage, and update.
+ (WebKit::WebPageProxy::preferencesDidChange):
+ - updateProccessSuppressionState -> updateThrottleState
+ (WebKit::WebPageProxy::updateActivityToken): Deleted.
+ (WebKit::WebPageProxy::updateProccessSuppressionState): Deleted.
+ (WebKit::WebPageProxy::updateThrottleState):
+ - Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
+ - Compute whether page should be suppressed, and send SetPageSuppressed message accordingly.
+ * UIProcess/WebPageProxy.h:
+ - Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
+ - Added setPageActivityState/m_activityState to report/record page activity.
+ - Added m_pageSuppressed to prevent redundant message sends.
+ * UIProcess/WebPageProxy.messages.in:
+ - Expose SetPageActivityState message (called by WebPage).
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+ - removed m_processSuppressionEnabled
+ - updateUserActivity -> setPageSuppressed - explicitly set the page to not be suppressed, until WebPageProxy tells us to do so.
+ (WebKit::WebPage::setPageActivityState):
+ - post activity state on to WebPageProxy.
+ (WebKit::WebPage::setPageSuppressed):
+ - Start/stop USerActivity accordingly.
+ (WebKit::WebPage::setViewState):
+ - No longer need to monitor ViewState changes on the WebProcess side.
+ (WebKit::WebPage::updatePreferences):
+ - No longer need to monitor preference changes on the WebProcess side.
+ (WebKit::WebPage::updateUserActivity): Deleted.
+ - Only updated on reciept of setPageSuppressed message.
+ * WebProcess/WebPage/WebPage.h:
+ - Removed m_activityState, m_processSuppressionEnabled, updateUserActivity.
+ - Added setPageSuppressed message.
+ * WebProcess/WebPage/WebPage.messages.in:
+ - Added SetPageSuppressed message.
+
2016-10-17 Michael Catanzaro <mcatanz...@igalia.com>
REGRESSION(r206189): logs error statements when API::URLRequest is canceled
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (207423 => 207424)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-10-17 20:18:38 UTC (rev 207424)
@@ -457,8 +457,7 @@
m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
updateViewState();
- updateActivityToken();
- updateProccessSuppressionState();
+ updateThrottleState();
updateHiddenPageThrottlingAutoIncreases();
#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
@@ -715,7 +714,7 @@
m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
updateViewState();
- updateActivityToken();
+ updateThrottleState();
m_inspector = WebInspectorProxy::create(this);
#if ENABLE(FULLSCREEN_API)
@@ -1538,7 +1537,7 @@
m_nextViewStateChangeCallbacks.clear();
// This must happen after the SetViewState message is sent, to ensure the page visibility event can fire.
- updateActivityToken();
+ updateThrottleState();
// 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
@@ -1563,13 +1562,34 @@
m_viewWasEverInWindow |= isNowInWindow;
}
+void WebPageProxy::setPageActivityState(WebCore::PageActivityState::Flags activityState)
+{
+ m_activityState = activityState;
+ updateThrottleState();
+}
+
bool WebPageProxy::isAlwaysOnLoggingAllowed() const
{
return sessionID().isAlwaysOnLoggingAllowed();
}
-void WebPageProxy::updateActivityToken()
+void WebPageProxy::updateThrottleState()
{
+ bool processSuppressionEnabled = m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
+
+ // If process suppression is not enabled take a token on the process pool to disable suppression of support processes.
+ if (!processSuppressionEnabled)
+ m_preventProcessSuppressionCount = m_process->processPool().processSuppressionDisabledForPageCount();
+ else if (!m_preventProcessSuppressionCount)
+ m_preventProcessSuppressionCount = nullptr;
+
+ // We should suppress if the page is not active, is visually idle, and supression is enabled.
+ bool pageShouldBeSuppressed = !m_activityState && processSuppressionEnabled && (m_viewState & ViewState::IsVisuallyIdle);
+ if (m_pageSuppressed != pageShouldBeSuppressed) {
+ m_pageSuppressed = pageShouldBeSuppressed;
+ m_process->send(Messages::WebPage::SetPageSuppressed(m_pageSuppressed), m_pageID);
+ }
+
if (m_viewState & ViewState::IsVisuallyIdle)
m_pageIsUserObservableCount = nullptr;
else if (!m_pageIsUserObservableCount)
@@ -1591,14 +1611,6 @@
#endif
}
-void WebPageProxy::updateProccessSuppressionState()
-{
- if (m_preferences->pageVisibilityBasedProcessSuppressionEnabled())
- m_preventProcessSuppressionCount = nullptr;
- else if (!m_preventProcessSuppressionCount)
- m_preventProcessSuppressionCount = m_process->processPool().processSuppressionDisabledForPageCount();
-}
-
void WebPageProxy::updateHiddenPageThrottlingAutoIncreases()
{
if (!m_preferences->hiddenPageDOMTimerThrottlingAutoIncreases())
@@ -3012,7 +3024,7 @@
inspector()->enableRemoteInspection();
#endif
- updateProccessSuppressionState();
+ updateThrottleState();
updateHiddenPageThrottlingAutoIncreases();
m_pageClient.preferencesDidChange();
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (207423 => 207424)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-10-17 20:18:38 UTC (rev 207424)
@@ -1137,8 +1137,7 @@
void platformInitialize();
void updateViewState(WebCore::ViewState::Flags flagsToUpdate = WebCore::ViewState::AllFlags);
- void updateActivityToken();
- void updateProccessSuppressionState();
+ void updateThrottleState();
void updateHiddenPageThrottlingAutoIncreases();
enum class ResetStateReason {
@@ -1520,6 +1519,7 @@
void dispatchViewStateChange();
void viewDidLeaveWindow();
void viewDidEnterWindow();
+ void setPageActivityState(WebCore::PageActivityState::Flags);
#if PLATFORM(MAC)
void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, const UserData&);
@@ -1713,6 +1713,8 @@
WebCore::PolicyAction m_syncNavigationActionPolicyAction;
DownloadID m_syncNavigationActionPolicyDownloadID;
bool m_shouldSuppressAppLinksInNextNavigationPolicyDecision { false };
+ WebCore::PageActivityState::Flags m_activityState { WebCore::PageActivityState::NoFlags };
+ bool m_pageSuppressed { false };
Deque<NativeWebKeyboardEvent> m_keyEventQueue;
Deque<NativeWebWheelEvent> m_wheelEventQueue;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (207423 => 207424)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2016-10-17 20:18:38 UTC (rev 207424)
@@ -408,7 +408,8 @@
#endif
DidUpdateViewState()
-
+ SetPageActivityState(int32_t pageActivityState)
+
DidSaveToPageCache()
#if ENABLE(SUBTLE_CRYPTO)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (207423 => 207424)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-10-17 20:18:38 UTC (rev 207424)
@@ -376,7 +376,6 @@
, m_scrollPinningBehavior(DoNotPin)
, m_useAsyncScrolling(false)
, m_viewState(parameters.viewState)
- , m_processSuppressionEnabled(true)
, m_userActivity("Process suppression disabled for page.")
, m_pendingNavigationID(0)
#if ENABLE(WEBGL)
@@ -495,7 +494,7 @@
m_page->setViewState(m_viewState);
if (!isVisible())
m_page->setIsPrerender();
- updateUserActivity();
+ setPageSuppressed(false);
updateIsInWindow(true);
@@ -582,21 +581,17 @@
void WebPage::setPageActivityState(PageActivityState::Flags activityState)
{
- PageActivityState::Flags changed = m_activityState ^ activityState;
- m_activityState = activityState;
-
- if (changed)
- updateUserActivity();
+ send(Messages::WebPageProxy::SetPageActivityState(activityState));
}
-void WebPage::updateUserActivity()
+void WebPage::setPageSuppressed(bool pageSuppressed)
{
- // 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)
+ // 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)
+ m_userActivity.stop();
+ else
m_userActivity.start();
- else
- m_userActivity.stop();
}
WebPage::~WebPage()
@@ -2595,9 +2590,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);
@@ -3233,12 +3225,6 @@
RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled(store.getBoolValueForKey(WebPreferencesKey::modernMediaControlsEnabledKey()));
- 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 (207423 => 207424)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-10-17 20:18:38 UTC (rev 207424)
@@ -926,6 +926,7 @@
bool shouldDispatchFakeMouseMoveEvents() const { return m_shouldDispatchFakeMouseMoveEvents; }
void setPageActivityState(WebCore::PageActivityState::Flags);
+ void setPageSuppressed(bool);
void postMessage(const String& messageName, API::Object* messageBody);
void postSynchronousMessageForTesting(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData);
@@ -1039,8 +1040,6 @@
void executeEditCommand(const String&, const String&);
void setEditable(bool);
- void updateUserActivity();
-
void mouseEvent(const WebMouseEvent&);
void keyEvent(const WebKeyboardEvent&);
#if ENABLE(IOS_TOUCH_EVENTS)
@@ -1476,9 +1475,7 @@
bool m_useAsyncScrolling;
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 (207423 => 207424)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-10-17 19:54:04 UTC (rev 207423)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-10-17 20:18:38 UTC (rev 207424)
@@ -24,6 +24,7 @@
SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, uint64_t callbackID)
SetViewState(unsigned viewState, bool wantsDidUpdateViewState, Vector<uint64_t> callbackIDs)
SetLayerHostingMode(enum WebKit::LayerHostingMode layerHostingMode)
+ SetPageSuppressed(bool pageSuppressed)
SetDrawsBackground(bool drawsBackground)