Prototype to stop more task queues.
This extends stopping to other task queues, beyond
timers and loading. This will be used to test various
breaking scenarios and edge cases.
Clean up flag structuring as part of this.
Bug:
Change-Id: I98c2a863ffb1aa5af711a026b764ba7dff928441
Reviewed-on: https://chromium-review.googlesource.com/803910
Commit-Queue: Shubhie Panicker <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Cr-Commit-Position: refs/heads/master@{#526644}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index c3f81e8..2561ffc 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -37,7 +37,6 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/features.h"
-#include "chrome/common/pause_tabs_field_trial.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_switches.h"
@@ -874,35 +873,6 @@
{"Learning", kSpeculativeResourcePrefetchingLearning,
arraysize(kSpeculativeResourcePrefetchingLearning), nullptr}};
-#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN)
-const FeatureEntry::FeatureParam kPauseBackgroundTabsMinimalEngagment[] = {
- {pausetabs::kFeatureName, pausetabs::kModeParamMinimal}};
-
-const FeatureEntry::FeatureParam kPauseBackgroundTabsLowEngagment[] = {
- {pausetabs::kFeatureName, pausetabs::kModeParamLow}};
-
-const FeatureEntry::FeatureParam kPauseBackgroundTabsMediumEngagment[] = {
- {pausetabs::kFeatureName, pausetabs::kModeParamMedium}};
-
-const FeatureEntry::FeatureParam kPauseBackgroundTabsHighEngagment[] = {
- {pausetabs::kFeatureName, pausetabs::kModeParamHigh}};
-
-const FeatureEntry::FeatureParam kPauseBackgroundTabsMaxEngagment[] = {
- {pausetabs::kFeatureName, pausetabs::kModeParamMax}};
-
-const FeatureEntry::FeatureVariation kPauseBackgroundTabsVariations[] = {
- {"minimal engagement", kPauseBackgroundTabsMinimalEngagment,
- arraysize(kPauseBackgroundTabsMinimalEngagment), nullptr},
- {"low engagement", kPauseBackgroundTabsLowEngagment,
- arraysize(kPauseBackgroundTabsLowEngagment), nullptr},
- {"medium engagement", kPauseBackgroundTabsMediumEngagment,
- arraysize(kPauseBackgroundTabsMediumEngagment), nullptr},
- {"high engagement", kPauseBackgroundTabsHighEngagment,
- arraysize(kPauseBackgroundTabsHighEngagment), nullptr},
- {"max engagement", kPauseBackgroundTabsMaxEngagment,
- arraysize(kPauseBackgroundTabsMaxEngagment), nullptr}};
-#endif
-
#if defined(OS_ANDROID)
const FeatureEntry::FeatureParam
kAutofillCreditCardPopupLayoutFeatureVariationIconAtStart[] = {
@@ -3094,14 +3064,6 @@
FEATURE_VALUE_TYPE(chrome::android::kCustomContextMenu)},
#endif // OS_ANDROID
-#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN)
- {pausetabs::kFeatureName, flag_descriptions::kPauseBackgroundTabsName,
- flag_descriptions::kPauseBackgroundTabsDescription, kOsDesktop,
- FEATURE_WITH_PARAMS_VALUE_TYPE(pausetabs::kFeature,
- kPauseBackgroundTabsVariations,
- "PauseBackgroundTabs")},
-#endif
-
#if defined(OS_CHROMEOS)
{"ash-disable-smooth-screen-rotation",
flag_descriptions::kAshDisableSmoothScreenRotationName,
@@ -3588,6 +3550,10 @@
flag_descriptions::kStopLoadingInBackgroundDescription, kOsAndroid,
FEATURE_VALUE_TYPE(features::kStopLoadingInBackground)},
+ {"stop-in-background", flag_descriptions::kStopInBackgroundName,
+ flag_descriptions::kStopInBackgroundDescription, kOsAll,
+ FEATURE_VALUE_TYPE(features::kStopInBackground)},
+
#if defined(TOOLKIT_VIEWS)
{"experimental-tab-controller",
flag_descriptions::kExperimentalTabControllerName,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 8d26b55dd..de7bb89 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -9,11 +9,6 @@
namespace flag_descriptions {
-const char kStopLoadingInBackgroundName[] = "Stop loading in background";
-const char kStopLoadingInBackgroundDescription[] =
- "Stop loading tasks and loading "
- "resources, in the background, after certain grace time.";
-
const char kAccelerated2dCanvasName[] = "Accelerated 2D canvas";
const char kAccelerated2dCanvasDescription[] =
"Enables the use of the GPU to perform 2d canvas rendering instead of "
@@ -1355,6 +1350,16 @@
const char kSpellingFeedbackFieldTrialDescription[] =
"Enable the field trial for sending user feedback to spelling service.";
+const char kStopInBackgroundName[] = "Stop in background";
+const char kStopInBackgroundDescription[] =
+ "Stop scheduler task queues, in the background, "
+ " after certain grace time.";
+
+const char kStopLoadingInBackgroundName[] = "Stop loading in background";
+const char kStopLoadingInBackgroundDescription[] =
+ "Stop loading tasks and loading "
+ "resources, in the background, after certain grace time.";
+
const char kSuggestionsWithSubStringMatchName[] =
"Substring matching for Autofill suggestions";
const char kSuggestionsWithSubStringMatchDescription[] =
@@ -2209,10 +2214,6 @@
"Show a OneGoogleBar on the local New Tab page if Google is the default "
"search engine.";
-const char kPauseBackgroundTabsName[] = "Pause background tabs";
-const char kPauseBackgroundTabsDescription[] =
- "Pause timers in background tabs after 5 minutes on desktop.";
-
const char kUseGoogleLocalNtpName[] = "Enable using the Google local NTP";
const char kUseGoogleLocalNtpDescription[] =
"Use the local New Tab page if Google is the default search engine.";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 677a21a8..9d4873a 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -825,6 +825,9 @@
extern const char kSpellingFeedbackFieldTrialName[];
extern const char kSpellingFeedbackFieldTrialDescription[];
+extern const char kStopInBackgroundName[];
+extern const char kStopInBackgroundDescription[];
+
extern const char kStopLoadingInBackgroundName[];
extern const char kStopLoadingInBackgroundDescription[];
@@ -1348,9 +1351,6 @@
extern const char kOneGoogleBarOnLocalNtpName[];
extern const char kOneGoogleBarOnLocalNtpDescription[];
-extern const char kPauseBackgroundTabsName[];
-extern const char kPauseBackgroundTabsDescription[];
-
extern const char kUseGoogleLocalNtpName[];
extern const char kUseGoogleLocalNtpDescription[];
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index ad3b9ed..55eef11 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -156,7 +156,6 @@
"page_load_metrics/page_track_decider.h",
"partial_circular_buffer.cc",
"partial_circular_buffer.h",
- "pause_tabs_field_trial.h",
"pdf_uma.cc",
"pdf_uma.h",
"pref_names_util.cc",
diff --git a/chrome/common/pause_tabs_field_trial.h b/chrome/common/pause_tabs_field_trial.h
deleted file mode 100644
index bbc8f69..0000000
--- a/chrome/common/pause_tabs_field_trial.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_PAUSE_TABS_FIELD_TRIAL_H_
-#define CHROME_COMMON_PAUSE_TABS_FIELD_TRIAL_H_
-
-#include "base/feature_list.h"
-
-namespace pausetabs {
-
-const base::Feature kFeature{"PauseBackgroundTabs",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
-const char kFeatureName[] = "pause-background-tabs";
-
-// Mode values.
-const char kModeParamMinimal[] = "minimal";
-const char kModeParamLow[] = "low";
-const char kModeParamMedium[] = "medium";
-const char kModeParamHigh[] = "high";
-const char kModeParamMax[] = "max";
-
-} // namespace pausetabs
-
-#endif // CHROME_COMMON_PAUSE_TABS_FIELD_TRIAL_H_
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 3346c213..aa14f288 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -30,7 +30,6 @@
#include "chrome/common/constants.mojom.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/features.h"
-#include "chrome/common/pause_tabs_field_trial.h"
#include "chrome/common/pdf_uma.h"
#include "chrome/common/pepper_permission_util.h"
#include "chrome/common/plugin.mojom.h"
@@ -1228,12 +1227,7 @@
}
bool ChromeContentRendererClient::AllowStoppingWhenProcessBackgrounded() {
-#if defined(OS_ANDROID)
- return true;
-#else
- // TODO(ojan): Plumb the engagement values for this feature to WebViewImpl.
- return base::FeatureList::IsEnabled(pausetabs::kFeature);
-#endif
+ return base::FeatureList::IsEnabled(features::kStopInBackground);
}
bool ChromeContentRendererClient::AllowPopup() {
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
index f8b8ff58..ae68a49e 100644
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -411,8 +411,11 @@
if (base::FeatureList::IsEnabled(features::kV8ContextSnapshot))
WebRuntimeFeatures::EnableV8ContextSnapshot(true);
+ if (base::FeatureList::IsEnabled(features::kStopInBackground))
+ WebRuntimeFeatures::EnableStopInBackground(true);
+
if (base::FeatureList::IsEnabled(features::kStopLoadingInBackground))
- WebRuntimeFeatures::EnableStopLoadingInBackgroundAndroid(true);
+ WebRuntimeFeatures::EnableStopLoadingInBackground(true);
WebRuntimeFeatures::EnablePWAFullCodeCache(
base::FeatureList::IsEnabled(features::kPWAFullCodeCache));
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
index d599efb5..1cc5948 100644
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -324,6 +324,16 @@
const base::Feature kSlimmingPaintInvalidation{
"SlimmingPaintInvalidation", base::FEATURE_ENABLED_BY_DEFAULT};
+// Stop scheduler task queues in background after allowed grace time.
+const base::Feature kStopInBackground {
+ "stop-in-background",
+#if defined(OS_ANDROID)
+ base::FEATURE_ENABLED_BY_DEFAULT
+#else
+ base::FEATURE_DISABLED_BY_DEFAULT
+#endif
+};
+
// Stop loading tasks and loading of resources in background, on Android,
// after allowed grace time. Launch bug: https://crbug.com/775761.
const base::Feature kStopLoadingInBackground{"stop-loading-in-background",
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
index b87fdf0d..91d19b0 100644
--- a/content/public/common/content_features.h
+++ b/content/public/common/content_features.h
@@ -85,6 +85,7 @@
CONTENT_EXPORT extern const base::Feature kSignInProcessIsolation;
CONTENT_EXPORT extern const base::Feature kSitePerProcess;
CONTENT_EXPORT extern const base::Feature kSlimmingPaintInvalidation;
+CONTENT_EXPORT extern const base::Feature kStopInBackground;
CONTENT_EXPORT extern const base::Feature kStopLoadingInBackground;
CONTENT_EXPORT extern const base::Feature kTimerThrottlingForHiddenFrames;
CONTENT_EXPORT extern const base::Feature kTopDocumentIsolation;
diff --git a/third_party/WebKit/Source/platform/exported/WebRuntimeFeatures.cpp b/third_party/WebKit/Source/platform/exported/WebRuntimeFeatures.cpp
index c9ee2d44..90fa9c2 100644
--- a/third_party/WebKit/Source/platform/exported/WebRuntimeFeatures.cpp
+++ b/third_party/WebKit/Source/platform/exported/WebRuntimeFeatures.cpp
@@ -486,8 +486,16 @@
RuntimeEnabledFeatures::SetWorkStealingInScriptRunnerEnabled(enable);
}
-void WebRuntimeFeatures::EnableStopLoadingInBackgroundAndroid(bool enable) {
- RuntimeEnabledFeatures::SetStopLoadingInBackgroundAndroidEnabled(enable);
+void WebRuntimeFeatures::EnableStopInBackground(bool enable) {
+ RuntimeEnabledFeatures::SetStopInBackgroundEnabled(enable);
+}
+
+void WebRuntimeFeatures::EnableStopLoadingInBackground(bool enable) {
+ RuntimeEnabledFeatures::SetStopLoadingInBackgroundEnabled(enable);
+}
+
+void WebRuntimeFeatures::EnableStopNonTimersInBackground(bool enable) {
+ RuntimeEnabledFeatures::SetStopNonTimersInBackgroundEnabled(enable);
}
void WebRuntimeFeatures::EnablePWAFullCodeCache(bool enable) {
diff --git a/third_party/WebKit/Source/platform/runtime_enabled_features.json5 b/third_party/WebKit/Source/platform/runtime_enabled_features.json5
index e174f92..714cda7f 100644
--- a/third_party/WebKit/Source/platform/runtime_enabled_features.json5
+++ b/third_party/WebKit/Source/platform/runtime_enabled_features.json5
@@ -1002,7 +1002,15 @@
status: "experimental",
},
{
- name: "StopLoadingInBackgroundAndroid",
+ name: "StopInBackground",
+ status: "test",
+ },
+ {
+ name: "StopLoadingInBackground",
+ status: "test",
+ },
+ {
+ name: "StopNonTimersInBackground",
status: "test",
},
{
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc
index 6ee65f4..44bfd51 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc
@@ -112,6 +112,10 @@
return ""; // MSVC needs that.
}
+bool StopLoadingInBackgroundEnabled() {
+ return RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled();
+}
+
} // namespace
RendererSchedulerImpl::RendererSchedulerImpl(
@@ -528,7 +532,7 @@
return NewTaskQueue(
MainThreadTaskQueue::QueueCreationParams(queue_type)
.SetCanBePaused(true)
- .SetCanBeStopped(true)
+ .SetCanBeStopped(StopLoadingInBackgroundEnabled())
.SetCanBeDeferred(true)
.SetUsedForControlTasks(
queue_type ==
@@ -1343,7 +1347,7 @@
if (main_thread_only().stopped_when_backgrounded) {
new_policy.timer_queue_policy().is_stopped = true;
- if (RuntimeEnabledFeatures::StopLoadingInBackgroundAndroidEnabled())
+ if (StopLoadingInBackgroundEnabled())
new_policy.loading_queue_policy().is_stopped = true;
}
if (main_thread_only().renderer_pause_count != 0) {
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc
index 1663d197..ef5bead 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc
@@ -2553,7 +2553,7 @@
}
TEST_F(RendererSchedulerImplTest, TestRendererBackgroundedLoadingSuspension) {
- ScopedStopLoadingInBackgroundAndroidForTest stop_loading_enabler(true);
+ ScopedStopLoadingInBackgroundForTest stop_loading_enabler(true);
scheduler_->SetStoppingWhenBackgroundedEnabled(true);
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc b/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
index 1e42413..c2dc9ba 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
@@ -56,6 +56,10 @@
}
}
+bool StopNonTimersInBackgroundEnabled() {
+ return RuntimeEnabledFeatures::StopNonTimersInBackgroundEnabled();
+}
+
} // namespace
WebFrameSchedulerImpl::ActiveConnectionHandleImpl::ActiveConnectionHandleImpl(
@@ -338,6 +342,7 @@
MainThreadTaskQueue::QueueType::kFrameThrottleable)
.SetShouldReportWhenExecutionBlocked(true)
.SetCanBeDeferred(true)
+ .SetCanBeStopped(StopNonTimersInBackgroundEnabled())
.SetCanBePaused(true));
deferrable_task_queue_->SetBlameContext(blame_context_);
deferrable_task_queue_->SetFrameScheduler(this);
@@ -355,6 +360,7 @@
MainThreadTaskQueue::QueueCreationParams(
MainThreadTaskQueue::QueueType::kFramePausable)
.SetShouldReportWhenExecutionBlocked(true)
+ .SetCanBeStopped(StopNonTimersInBackgroundEnabled())
.SetCanBePaused(true));
pausable_task_queue_->SetBlameContext(blame_context_);
pausable_task_queue_->SetFrameScheduler(this);
@@ -507,7 +513,7 @@
WebFrameScheduler::ThrottlingState
WebFrameSchedulerImpl::CalculateThrottlingState() const {
- if (RuntimeEnabledFeatures::StopLoadingInBackgroundAndroidEnabled() &&
+ if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled() &&
page_stopped_) {
DCHECK(!page_visible_);
return WebFrameScheduler::ThrottlingState::kStopped;
diff --git a/third_party/WebKit/public/platform/WebRuntimeFeatures.h b/third_party/WebKit/public/platform/WebRuntimeFeatures.h
index a76b897..9b5a573 100644
--- a/third_party/WebKit/public/platform/WebRuntimeFeatures.h
+++ b/third_party/WebKit/public/platform/WebRuntimeFeatures.h
@@ -183,7 +183,9 @@
BLINK_PLATFORM_EXPORT static void EnableV8ContextSnapshot(bool);
BLINK_PLATFORM_EXPORT static void EnableAutomationControlled(bool);
BLINK_PLATFORM_EXPORT static void EnableWorkStealingInScriptRunner(bool);
- BLINK_PLATFORM_EXPORT static void EnableStopLoadingInBackgroundAndroid(bool);
+ BLINK_PLATFORM_EXPORT static void EnableStopInBackground(bool);
+ BLINK_PLATFORM_EXPORT static void EnableStopLoadingInBackground(bool);
+ BLINK_PLATFORM_EXPORT static void EnableStopNonTimersInBackground(bool);
BLINK_PLATFORM_EXPORT static void EnablePWAFullCodeCache(bool);
BLINK_PLATFORM_EXPORT static void EnableDoubleTapToJumpOnVideo(bool);
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 7d03bdb..43f343e 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -24955,6 +24955,7 @@
<int value="-1490298774" label="enable-captive-portal-bypass-proxy-option"/>
<int value="-1488744539" label="QuickUnlockFingerprint:enabled"/>
<int value="-1487243228" label="NewUsbBackend:disabled"/>
+ <int value="-1482730792" label="stop-in-background:enabled"/>
<int value="-1482685863" label="enable-request-tablet-site"/>
<int value="-1480926949" label="MaterialDesignBookmarks:enabled"/>
<int value="-1480866718" label="ash-disable-login-dim-and-blur"/>
@@ -26181,6 +26182,7 @@
<int value="1827369558" label="AndroidPayIntegrationV1:disabled"/>
<int value="1828660283" label="enable-webfonts-intervention-trigger"/>
<int value="1830460973" label="disable-network-settings-config"/>
+ <int value="1831593339" label="stop-in-background:disabled"/>
<int value="1831835753" label="MaterialDesignIncognitoNTP:enabled"/>
<int value="1835523483" label="OmniboxUIExperimentSwapTitleAndUrl:enabled"/>
<int value="1838990777" label="V8Future:enabled"/>