Client should be able to disable PSON even if the experimental feature is on by default
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 18:13:13 +0000 (18:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 18:13:13 +0000 (18:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191634

Reviewed by Dean Jackson.

Instead of overriding the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag to true
when the experimental is enabled, use a separate flag to store this information. If the client
explicitly sets the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag then we obey
the client's request, otherwise, we fall back to using the state from experimental features.

This allows:
- API tests to explicitely disable PSON / Process prewarming even if those are on by default
  in experimental features.
- If the client does not set those flags on the APIProcessPoolConfiguration (Safari for e.g.),
  then the experimental feature flag still fully controls the feature.

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createWebPage):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit/UIProcess/WebProcessPool.cpp

index ed9fb08..0f9a893 100644 (file)
@@ -1,5 +1,29 @@
 2018-11-14  Chris Dumez  <cdumez@apple.com>
 
+        Client should be able to disable PSON even if the experimental feature is on by default
+        https://bugs.webkit.org/show_bug.cgi?id=191634
+
+        Reviewed by Dean Jackson.
+
+        Instead of overriding the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag to true
+        when the experimental is enabled, use a separate flag to store this information. If the client
+        explicitly sets the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag then we obey
+        the client's request, otherwise, we fall back to using the state from experimental features.
+
+        This allows:
+        - API tests to explicitely disable PSON / Process prewarming even if those are on by default
+          in experimental features.
+        - If the client does not set those flags on the APIProcessPoolConfiguration (Safari for e.g.),
+          then the experimental feature flag still fully controls the feature.
+
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::createWebPage):
+
+2018-11-14  Chris Dumez  <cdumez@apple.com>
+
         WebKit.ApplicationManifestBasic API test is failing when enabling PSON
         https://bugs.webkit.org/show_bug.cgi?id=191602
 
index 4ea00a2..ee12aa2 100644 (file)
@@ -120,10 +120,11 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
     copy->m_ctDataConnectionServiceType = this->m_ctDataConnectionServiceType;
 #endif
     copy->m_presentingApplicationPID = this->m_presentingApplicationPID;
-    copy->m_processSwapsOnNavigation = this->m_processSwapsOnNavigation;
+    copy->m_processSwapsOnNavigationFromClient = this->m_processSwapsOnNavigationFromClient;
+    copy->m_processSwapsOnNavigationFromExperimentalFeatures = this->m_processSwapsOnNavigationFromExperimentalFeatures;
     copy->m_alwaysKeepAndReuseSwappedProcesses = this->m_alwaysKeepAndReuseSwappedProcesses;
     copy->m_processSwapsOnWindowOpenWithOpener = this->m_processSwapsOnWindowOpenWithOpener;
-    copy->m_isAutomaticProcessWarmingEnabled = this->m_isAutomaticProcessWarmingEnabled;
+    copy->m_isAutomaticProcessWarmingEnabledByClient = this->m_isAutomaticProcessWarmingEnabledByClient;
 #if ENABLE(PROXIMITY_NETWORKING)
     copy->m_wirelessContextIdentifier = this->m_wirelessContextIdentifier;
 #endif
index e22ffb4..9a564b0 100644 (file)
@@ -59,8 +59,13 @@ public:
     unsigned maximumProcessCount() const { return m_maximumProcessCount; }
     void setMaximumProcessCount(unsigned maximumProcessCount) { m_maximumProcessCount = maximumProcessCount; }
 
-    bool isAutomaticProcessWarmingEnabled() const { return m_isAutomaticProcessWarmingEnabled; }
-    void setIsAutomaticProcessWarmingEnabled(bool value) { m_isAutomaticProcessWarmingEnabled = value; }
+    bool isAutomaticProcessWarmingEnabled() const
+    {
+        // FIXME: For now, turning on PSON from the experimental features menu also turns on
+        // automatic process warming until clients can be updated.
+        return m_isAutomaticProcessWarmingEnabledByClient.value_or(m_processSwapsOnNavigationFromExperimentalFeatures);
+    }
+    void setIsAutomaticProcessWarmingEnabled(bool value) { m_isAutomaticProcessWarmingEnabledByClient = value; }
 
     bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; }
     void setDiskCacheSpeculativeValidationEnabled(bool enabled) { m_diskCacheSpeculativeValidationEnabled = enabled; }
@@ -150,8 +155,12 @@ public:
     ProcessID presentingApplicationPID() const { return m_presentingApplicationPID; }
     void setPresentingApplicationPID(ProcessID pid) { m_presentingApplicationPID = pid; }
 
-    bool processSwapsOnNavigation() const { return m_processSwapsOnNavigation; }
-    void setProcessSwapsOnNavigation(bool swaps) { m_processSwapsOnNavigation = swaps; }
+    bool processSwapsOnNavigation() const
+    {
+        return m_processSwapsOnNavigationFromClient.value_or(m_processSwapsOnNavigationFromExperimentalFeatures);
+    }
+    void setProcessSwapsOnNavigation(bool swaps) { m_processSwapsOnNavigationFromClient = swaps; }
+    void setProcessSwapsOnNavigationFromExperimentalFeatures(bool swaps) { m_processSwapsOnNavigationFromExperimentalFeatures = swaps; }
 
     bool alwaysKeepAndReuseSwappedProcesses() const { return m_alwaysKeepAndReuseSwappedProcesses; }
     void setAlwaysKeepAndReuseSwappedProcesses(bool keepAndReuse) { m_alwaysKeepAndReuseSwappedProcesses = keepAndReuse; }
@@ -205,10 +214,11 @@ private:
     bool m_shouldCaptureAudioInUIProcess { false };
     bool m_shouldCaptureDisplayInUIProcess { DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS };
     ProcessID m_presentingApplicationPID { getCurrentProcessID() };
-    bool m_processSwapsOnNavigation { false };
+    std::optional<bool> m_processSwapsOnNavigationFromClient;
+    bool m_processSwapsOnNavigationFromExperimentalFeatures { false };
     bool m_alwaysKeepAndReuseSwappedProcesses { false };
     bool m_processSwapsOnWindowOpenWithOpener { false };
-    bool m_isAutomaticProcessWarmingEnabled { false };
+    std::optional<bool> m_isAutomaticProcessWarmingEnabledByClient { false };
     WTF::String m_customWebContentServiceBundleIdentifier;
 
 #if PLATFORM(IOS_FAMILY)
index 55f107d..f6f07e2 100644 (file)
@@ -1126,12 +1126,7 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
 #endif
 
     auto page = process->createWebPage(pageClient, WTFMove(pageConfiguration));
-    if (page->preferences().processSwapOnCrossSiteNavigationEnabled()) {
-        m_configuration->setProcessSwapsOnNavigation(true);
-        // FIXME: For now, turning on PSON from the debug features menu also turns on
-        // automatic process warming until clients can be updated.
-        m_configuration->setIsAutomaticProcessWarmingEnabled(true);
-    }
+    m_configuration->setProcessSwapsOnNavigationFromExperimentalFeatures(page->preferences().processSwapOnCrossSiteNavigationEnabled());
 
     return page;
 }