Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Unified Diff: third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc

Issue 2476973002: [scheduler] Report background timer throttling intervention. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc b/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
index f7ba68c71c706abc2f5cb8692294400ea498420e..2072b56ab50f56f9e5aa82664444ab38d0d0b9d6 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
@@ -5,6 +5,7 @@
#include "platform/scheduler/renderer/web_view_scheduler_impl.h"
#include "base/logging.h"
+#include "base/strings/stringprintf.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/scheduler/base/virtual_time_domain.h"
#include "platform/scheduler/child/scheduler_tqm_delegate.h"
@@ -19,6 +20,10 @@ namespace scheduler {
namespace {
const double kBackgroundBudgetAsCPUFraction = .01;
+// Given that we already align timers to 1Hz, do not report throttling if
+// it is under 3s.
+constexpr base::TimeDelta kMinimalThrottlingDurationToReport =
Sami 2016/11/04 17:51:49 kMinimalThrottlingDurationToReport since we report
altimin 2016/11/07 17:25:30 Did you mean kMinimalBackgroundThrottlingDurationT
+ base::TimeDelta::FromSeconds(3);
} // namespace
@@ -198,5 +203,20 @@ bool WebViewSchedulerImpl::IsAudioPlaying() const {
return is_audio_playing_;
}
+void WebViewSchedulerImpl::OnThrottlingReported(
+ base::TimeDelta throttling_duration) {
+ if (throttling_duration < kMinimalThrottlingDurationToReport)
+ return;
+
+ std::string message = base::StringPrintf(
+ "Background timers take too long to run on this page. "
Sami 2016/11/04 17:51:49 To rephrase a bit: "Timer tasks have used too muc
altimin 2016/11/07 17:25:30 Done.
+ "They have been throttled for %.3f seconds. "
+ "See https://www.chromestatus.com/feature/6172836527865856 "
+ " for more details",
+ throttling_duration.InSecondsF());
+
+ intervention_reporter_->ReportIntervention(WebString::fromUTF8(message));
Sami 2016/11/04 17:51:49 Is this potentially spammy? I wonder if we should
altimin 2016/11/07 17:25:30 Done.
+}
+
} // namespace scheduler
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698