123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: deepak1556 <[email protected]>
- Date: Mon, 18 May 2020 11:12:26 -0700
- Subject: feat: allow disabling blink scheduler throttling per RenderView
- This allows us to disable throttling for hidden windows.
- diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
- index 00644aa7553c815753b5f47d4489614657cc770f..1050e3fca362fd898f150c0f15d7a92dcdd95cae 100644
- --- a/content/browser/renderer_host/render_view_host_impl.cc
- +++ b/content/browser/renderer_host/render_view_host_impl.cc
- @@ -609,6 +609,11 @@ void RenderViewHostImpl::SetBackgroundOpaque(bool opaque) {
- GetWidget()->GetAssociatedFrameWidget()->SetBackgroundOpaque(opaque);
- }
-
- +void RenderViewHostImpl::SetSchedulerThrottling(bool allowed) {
- + if (auto& broadcast = GetAssociatedPageBroadcast())
- + broadcast->SetSchedulerThrottling(allowed);
- +}
- +
- bool RenderViewHostImpl::IsMainFrameActive() {
- return is_active();
- }
- diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
- index b9b5b0984f5313b1e90999cde027b2e987e3bef8..12c99cf6ff021aa43cf32f9eb3021af6463fc742 100644
- --- a/content/browser/renderer_host/render_view_host_impl.h
- +++ b/content/browser/renderer_host/render_view_host_impl.h
- @@ -135,6 +135,7 @@ class CONTENT_EXPORT RenderViewHostImpl
- bool IsRenderViewLive() override;
- void WriteIntoTracedValue(perfetto::TracedValue context) override;
-
- + void SetSchedulerThrottling(bool allowed) override;
- void SendWebPreferencesToRenderer();
- void SendRendererPreferencesToRenderer(
- const blink::RendererPreferences& preferences);
- diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h
- index 59b281ca58f7ea8cf20f809a85fffef4fd3c9eec..e27942ee8a436d80d2f441925b751e7bd3cf7132 100644
- --- a/content/public/browser/render_view_host.h
- +++ b/content/public/browser/render_view_host.h
- @@ -91,6 +91,9 @@ class CONTENT_EXPORT RenderViewHost {
- // Write a representation of this object into a trace.
- virtual void WriteIntoTracedValue(perfetto::TracedValue context) = 0;
-
- + // Disable/Enable scheduler throttling.
- + virtual void SetSchedulerThrottling(bool allowed) = 0;
- +
- private:
- // This interface should only be implemented inside content.
- friend class RenderViewHostImpl;
- diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
- index 1d8ffde83fa97ff516e2cbc2add520da7b955750..4db10afe645a36ccac56d9afda95fd1fb3eaadf7 100644
- --- a/content/renderer/render_view_impl.h
- +++ b/content/renderer/render_view_impl.h
- @@ -211,6 +211,8 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
- static WindowOpenDisposition NavigationPolicyToDisposition(
- blink::WebNavigationPolicy policy);
-
- + void OnSetSchedulerThrottling(bool allowed);
- +
- // Misc private functions ----------------------------------------------------
-
- #if defined(OS_ANDROID)
- diff --git a/third_party/blink/public/mojom/page/page.mojom b/third_party/blink/public/mojom/page/page.mojom
- index e122d4ffb857023841dabcb6fed352d7586d8344..3c7cd1cb8b204024a0835150302ee8896e01ee45 100644
- --- a/third_party/blink/public/mojom/page/page.mojom
- +++ b/third_party/blink/public/mojom/page/page.mojom
- @@ -73,4 +73,7 @@ interface PageBroadcast {
-
- // Set history offset and length.
- SetHistoryOffsetAndLength(int32 offset, int32 length);
- +
- + // Whether to enable the Renderer scheduler background throttling.
- + SetSchedulerThrottling(bool allowed);
- };
- diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h
- index 209067240ccce0458882ad008363cdb996dd1a80..eaacca18d1488b3a2f7445bb44949ccb9e8e3453 100644
- --- a/third_party/blink/public/web/web_view.h
- +++ b/third_party/blink/public/web/web_view.h
- @@ -348,6 +348,7 @@ class WebView {
- // Scheduling -----------------------------------------------------------
-
- virtual PageScheduler* Scheduler() const = 0;
- + virtual void SetSchedulerThrottling(bool allowed) = 0;
-
- // Visibility -----------------------------------------------------------
-
- diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
- index 4b7adb536a285501bb8dbeccd6bbb813cdf903c6..d7ada5c44ba02449ab11d4cb5a6f201ea6adf9f6 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.cc
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
- @@ -3551,6 +3551,13 @@ PageScheduler* WebViewImpl::Scheduler() const {
- return GetPage()->GetPageScheduler();
- }
-
- +void WebViewImpl::SetSchedulerThrottling(bool allowed) {
- + DCHECK(GetPage());
- + scheduler_throttling_allowed_ = allowed;
- + GetPage()->GetPageScheduler()->SetPageVisible(allowed ?
- + (GetVisibilityState() == mojom::blink::PageVisibilityState::kVisible) : true);
- +}
- +
- void WebViewImpl::SetVisibilityState(
- mojom::blink::PageVisibilityState visibility_state,
- bool is_initial_state) {
- @@ -3563,7 +3570,8 @@ void WebViewImpl::SetVisibilityState(
- }
- GetPage()->SetVisibilityState(visibility_state, is_initial_state);
- GetPage()->GetPageScheduler()->SetPageVisible(
- - visibility_state == mojom::blink::PageVisibilityState::kVisible);
- + scheduler_throttling_allowed_ ?
- + (visibility_state == mojom::blink::PageVisibilityState::kVisible) : true);
- }
-
- mojom::blink::PageVisibilityState WebViewImpl::GetVisibilityState() {
- diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h
- index ace66b559cdc53c81b6b303a18a0c425e9a74789..5c4b0110e67b51877405fd49b497404201ce9dbc 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.h
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
- @@ -391,6 +391,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
- LocalDOMWindow* PagePopupWindow() const;
-
- PageScheduler* Scheduler() const override;
- + void SetSchedulerThrottling(bool allowed) override;
- void SetVisibilityState(mojom::blink::PageVisibilityState visibility_state,
- bool is_initial_state) override;
- mojom::blink::PageVisibilityState GetVisibilityState() override;
- @@ -800,11 +801,18 @@ class CORE_EXPORT WebViewImpl final : public WebView,
-
- float zoom_factor_override_ = 0.f;
-
- + // TODO(bokan): Temporary debugging added to diagnose
- + // https://crbug.com/992315. Somehow we're synchronously calling
- + // WebViewImpl::Close while handling an input event.
- + bool debug_inside_input_handling_ = false;
- +
- FloatSize elastic_overscroll_;
-
- // If true, we send IPC messages when |preferred_size_| changes.
- bool send_preferred_size_changes_ = false;
-
- + bool scheduler_throttling_allowed_ = true;
- +
- // Whether the preferred size may have changed and |UpdatePreferredSize| needs
- // to be called.
- bool needs_preferred_size_update_ = true;
|