123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: deepak1556 <[email protected]>
- Date: Mon, 18 May 2020 11:12:26 -0700
- Subject: 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 84044606fb0644b2b6053c72a9750bae3729f666..995c5dfc49a392669f73d85a92fbdb54cf0e11ca 100644
- --- a/content/browser/renderer_host/render_view_host_impl.cc
- +++ b/content/browser/renderer_host/render_view_host_impl.cc
- @@ -649,6 +649,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 a099eed10dd061994bff696519099c3ef7437a46..a1f1e9b55272e70b4acd5d1f1515fba7d91538fa 100644
- --- a/content/browser/renderer_host/render_view_host_impl.h
- +++ b/content/browser/renderer_host/render_view_host_impl.h
- @@ -137,6 +137,7 @@ class CONTENT_EXPORT RenderViewHostImpl
- bool IsRenderViewLive() const override;
- void WriteIntoTrace(perfetto::TracedProto<TraceProto> context) const 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 a6fe708878eb9afba9a68e0be71ba2c0b2a84d7d..5cc81ceb44d0a8baee3ebcc63aa4137b1e9ef08e 100644
- --- a/content/public/browser/render_view_host.h
- +++ b/content/public/browser/render_view_host.h
- @@ -80,6 +80,9 @@ class CONTENT_EXPORT RenderViewHost {
- virtual void WriteIntoTrace(
- perfetto::TracedProto<TraceProto> context) const = 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 4e8d36420d6edc1725a840e1b9f123041d21abe4..dd198cb7bf02e509833c6b4c7d8e5d65d20d46dc 100644
- --- a/content/renderer/render_view_impl.h
- +++ b/content/renderer/render_view_impl.h
- @@ -152,6 +152,8 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
- static WindowOpenDisposition NavigationPolicyToDisposition(
- blink::WebNavigationPolicy policy);
-
- + void OnSetSchedulerThrottling(bool allowed);
- +
- // ---------------------------------------------------------------------------
- // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
- // it in the same order in the .cc file as it was in the header.
- diff --git a/third_party/blink/public/mojom/page/page.mojom b/third_party/blink/public/mojom/page/page.mojom
- index befd736a9cf362514b9a2ee475dc4a814c85a87b..24b2617f56673a3075697802cf5b574b0c766610 100644
- --- a/third_party/blink/public/mojom/page/page.mojom
- +++ b/third_party/blink/public/mojom/page/page.mojom
- @@ -97,4 +97,7 @@ interface PageBroadcast {
-
- // Sent to whole page, but should only be used by the main frame.
- SetPageBaseBackgroundColor(skia.mojom.SkColor? color);
- +
- + // 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 560b72dfbc70172bc668229b29fe0c9da139f320..13ec73b9d627259625d64f5b97838033db89745c 100644
- --- a/third_party/blink/public/web/web_view.h
- +++ b/third_party/blink/public/web/web_view.h
- @@ -369,6 +369,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 daab024ee0e2010e177eabeb7e0fb964c631dd17..06d8ca44fb1dc3748d81b5c5a407dfdf7183f845 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.cc
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
- @@ -3666,6 +3666,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) {
- @@ -3677,7 +3684,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 5107ef421138e136b20b25b7bbcc1f0bb246bb66..043266205142e59f88c4c2f2ae6b58bb009f2d9c 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.h
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
- @@ -420,6 +420,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;
- @@ -857,6 +858,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
- // 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;
|