Title: [207346] trunk/Source/WebKit2
Revision
207346
Author
barraclo...@apple.com
Date
2016-10-14 11:06:47 -0700 (Fri, 14 Oct 2016)

Log Message

Add API to restrict WebKit processes to background priority
https://bugs.webkit.org/show_bug.cgi?id=163363

Reviewed by Anders Carlson.

Add API on _WKProcessPoolConfiguration to flag a process pool as 'alwaysRunsAtBackgroundPriority'.
WebContent and Networking processes associated with that pool will only run a background priority,
when they otherwise would have run at foreground priority.

* UIProcess/API/APIProcessPoolConfiguration.h:
    - Add m_alwaysRunsAtBackgroundPriority flag to pool configuration object.
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration alwaysRunsAtBackgroundPriority]):
(-[_WKProcessPoolConfiguration setAlwaysRunsAtBackgroundPriority:]):
    - Expose new configuration property through API.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::alwaysRunsAtBackgroundPriority):
* UIProcess/Network/NetworkProcessProxy.h:
    - Support ProcessThrottlerClient interface to check if alwaysRunsAtBackgroundPriority is set.
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::assertionState):
    - When determining whether to take a foreground exception check alwaysRunsAtBackgroundPriority.
* UIProcess/ProcessThrottlerClient.h:
    - Add interface to access alwaysRunsAtBackgroundPriority state of WebProcess of NetworkProcess.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool):
* UIProcess/WebProcessPool.h:
    - Add m_alwaysRunsAtBackgroundPriority, set by configuration.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::alwaysRunsAtBackgroundPriority):
* UIProcess/WebProcessProxy.h:
    - Support ProcessThrottlerClient interface to check if alwaysRunsAtBackgroundPriority is set.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (207345 => 207346)


--- trunk/Source/WebKit2/ChangeLog	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-14 18:06:47 UTC (rev 207346)
@@ -1,3 +1,39 @@
+2016-10-14  Gavin Barraclough  <barraclo...@apple.com>
+
+        Add API to restrict WebKit processes to background priority
+        https://bugs.webkit.org/show_bug.cgi?id=163363
+
+        Reviewed by Anders Carlson.
+
+        Add API on _WKProcessPoolConfiguration to flag a process pool as 'alwaysRunsAtBackgroundPriority'.
+        WebContent and Networking processes associated with that pool will only run a background priority,
+        when they otherwise would have run at foreground priority.
+
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+            - Add m_alwaysRunsAtBackgroundPriority flag to pool configuration object.
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration alwaysRunsAtBackgroundPriority]):
+        (-[_WKProcessPoolConfiguration setAlwaysRunsAtBackgroundPriority:]):
+            - Expose new configuration property through API.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::alwaysRunsAtBackgroundPriority):
+        * UIProcess/Network/NetworkProcessProxy.h:
+            - Support ProcessThrottlerClient interface to check if alwaysRunsAtBackgroundPriority is set.
+        * UIProcess/ProcessThrottler.cpp:
+        (WebKit::ProcessThrottler::assertionState):
+            - When determining whether to take a foreground exception check alwaysRunsAtBackgroundPriority.
+        * UIProcess/ProcessThrottlerClient.h:
+            - Add interface to access alwaysRunsAtBackgroundPriority state of WebProcess of NetworkProcess.
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::WebProcessPool):
+        * UIProcess/WebProcessPool.h:
+            - Add m_alwaysRunsAtBackgroundPriority, set by configuration.
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::alwaysRunsAtBackgroundPriority):
+        * UIProcess/WebProcessProxy.h:
+            - Support ProcessThrottlerClient interface to check if alwaysRunsAtBackgroundPriority is set.
+
 2016-10-14  Youenn Fablet  <you...@apple.com>
 
         Make NetworkCache aware of fetch cache mode

Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp	2016-10-14 18:06:47 UTC (rev 207346)
@@ -113,6 +113,7 @@
     copy->m_overrideLanguages = this->m_overrideLanguages;
     copy->m_sourceApplicationBundleIdentifier = this->m_sourceApplicationBundleIdentifier;
     copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier;
+    copy->m_alwaysRunsAtBackgroundPriority = this->m_alwaysRunsAtBackgroundPriority;
 #if PLATFORM(IOS)
     copy->m_ctDataConnectionServiceType = this->m_ctDataConnectionServiceType;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -108,6 +108,9 @@
     const WTF::String& sourceApplicationSecondaryIdentifier() const { return m_sourceApplicationSecondaryIdentifier; }
     void setSourceApplicationSecondaryIdentifier(const WTF::String& sourceApplicationSecondaryIdentifier) { m_sourceApplicationSecondaryIdentifier = sourceApplicationSecondaryIdentifier; }
 
+    bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
+    void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; }
+
 #if PLATFORM(IOS)
     const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; }
     void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; }
@@ -138,6 +141,7 @@
     Vector<WTF::String> m_overrideLanguages;
     WTF::String m_sourceApplicationBundleIdentifier;
     WTF::String m_sourceApplicationSecondaryIdentifier;
+    bool m_alwaysRunsAtBackgroundPriority { false };
 #if PLATFORM(IOS)
     WTF::String m_ctDataConnectionServiceType;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -49,6 +49,7 @@
 @property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 #if TARGET_OS_IPHONE
 @property (nonatomic, nullable, copy) NSString *CTDataConnectionServiceType WK_API_AVAILABLE(ios(WK_IOS_TBA));
+@property (nonatomic) BOOL alwaysRunsAtBackgroundPriority WK_API_AVAILABLE(ios(WK_IOS_TBA));
 #endif
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2016-10-14 18:06:47 UTC (rev 207346)
@@ -181,6 +181,16 @@
 {
     _processPoolConfiguration->setCTDataConnectionServiceType(ctDataConnectionServiceType);
 }
+
+- (BOOL)alwaysRunsAtBackgroundPriority
+{
+    return _processPoolConfiguration->alwaysRunsAtBackgroundPriority();
+}
+
+- (void)setAlwaysRunsAtBackgroundPriority:(BOOL)alwaysRunsAtBackgroundPriority
+{
+    _processPoolConfiguration->setAlwaysRunsAtBackgroundPriority(alwaysRunsAtBackgroundPriority);
+}
 #endif
 
 - (NSString *)description

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2016-10-14 18:06:47 UTC (rev 207346)
@@ -390,6 +390,11 @@
         send(Messages::NetworkProcess::ProcessDidResume(), 0);
 }
 
+bool NetworkProcessProxy::alwaysRunsAtBackgroundPriority()
+{
+    return m_processPool.alwaysRunsAtBackgroundPriority();
+}
+
 void NetworkProcessProxy::processReadyToSuspend()
 {
     m_throttler.processReadyToSuspend();

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -91,6 +91,7 @@
     void sendPrepareToSuspend() override;
     void sendCancelPrepareToSuspend() override;
     void sendProcessDidResume() override;
+    bool alwaysRunsAtBackgroundPriority() override;
     void didSetAssertionState(AssertionState) override;
 
     // IPC::Connection::Client

Modified: trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp	2016-10-14 18:06:47 UTC (rev 207346)
@@ -47,7 +47,7 @@
     ASSERT(!m_suspendTimer.isActive());
     
     if (m_foregroundCounter.value())
-        return AssertionState::Foreground;
+        return m_process.alwaysRunsAtBackgroundPriority() ? AssertionState::Background : AssertionState::Foreground;
     if (m_backgroundCounter.value())
         return AssertionState::Background;
     return AssertionState::Suspended;

Modified: trunk/Source/WebKit2/UIProcess/ProcessThrottlerClient.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/ProcessThrottlerClient.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/ProcessThrottlerClient.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -38,7 +38,7 @@
     virtual void sendPrepareToSuspend() = 0;
     virtual void sendCancelPrepareToSuspend() = 0;
     virtual void sendProcessDidResume() = 0;
-
+    virtual bool alwaysRunsAtBackgroundPriority() = 0;
     virtual void didSetAssertionState(AssertionState) = 0;
 };
 

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2016-10-14 18:06:47 UTC (rev 207346)
@@ -177,6 +177,7 @@
     , m_canHandleHTTPSServerTrustEvaluation(true)
     , m_didNetworkProcessCrash(false)
     , m_memoryCacheDisabled(false)
+    , m_alwaysRunsAtBackgroundPriority(m_configuration->alwaysRunsAtBackgroundPriority())
     , m_userObservablePageCounter([this](RefCounterEvent) { updateProcessSuppressionState(); })
     , m_processSuppressionDisabledForPageCounter([this](RefCounterEvent) { updateProcessSuppressionState(); })
     , m_hiddenPageThrottlingAutoIncreasesCounter([this](RefCounterEvent) { m_hiddenPageThrottlingTimer.startOneShot(0); })

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -366,6 +366,8 @@
     bool resourceLoadStatisticsEnabled() { return m_resourceLoadStatisticsEnabled; }
     void setResourceLoadStatisticsEnabled(bool enabled) { m_resourceLoadStatisticsEnabled = enabled; }
 
+    bool alwaysRunsAtBackgroundPriority() { return m_alwaysRunsAtBackgroundPriority; }
+
 #if ENABLE(GAMEPAD)
     void gamepadConnected(const UIGamepad&);
     void gamepadDisconnected(const UIGamepad&);
@@ -533,6 +535,8 @@
     bool m_memoryCacheDisabled;
     bool m_resourceLoadStatisticsEnabled { false };
 
+    bool m_alwaysRunsAtBackgroundPriority;
+
     UserObservablePageCounter m_userObservablePageCounter;
     ProcessSuppressionDisabledCounter m_processSuppressionDisabledForPageCounter;
     HiddenPageThrottlingAutoIncreasesCounter m_hiddenPageThrottlingAutoIncreasesCounter;

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2016-10-14 18:06:47 UTC (rev 207346)
@@ -927,6 +927,11 @@
         send(Messages::WebProcess::ProcessDidResume(), 0);
 }
 
+bool WebProcessProxy::alwaysRunsAtBackgroundPriority()
+{
+    return m_processPool->alwaysRunsAtBackgroundPriority();
+}
+
 void WebProcessProxy::processReadyToSuspend()
 {
     m_throttler.processReadyToSuspend();

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (207345 => 207346)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2016-10-14 17:14:39 UTC (rev 207345)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2016-10-14 18:06:47 UTC (rev 207346)
@@ -208,6 +208,7 @@
     void sendPrepareToSuspend() override;
     void sendCancelPrepareToSuspend() override;
     void sendProcessDidResume() override;
+    bool alwaysRunsAtBackgroundPriority() override;
     void didSetAssertionState(AssertionState) override;
 
     // ProcessLauncher::Client
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to