123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: deepak1556 <[email protected]>
- Date: Fri, 29 Nov 2019 16:08:14 -0800
- 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 9a2cc0f076406d68910eeb5351e3869287515fcb..bde2f593f55edc677d44f4ae037042fe10661679 100644
- --- a/content/browser/renderer_host/render_view_host_impl.cc
- +++ b/content/browser/renderer_host/render_view_host_impl.cc
- @@ -512,6 +512,10 @@ void RenderViewHostImpl::SetBackgroundOpaque(bool opaque) {
- GetWidget()->GetAssociatedFrameWidget()->SetBackgroundOpaque(opaque);
- }
-
- +void RenderViewHostImpl::SetSchedulerThrottling(bool allowed) {
- + Send(new ViewMsg_SetSchedulerThrottling(GetRoutingID(), 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 af15805b34d2cc038e73654017d4c0921e3fc321..3489f03bac1283efb6a27f5b959a72a8e5d0cb14 100644
- --- a/content/browser/renderer_host/render_view_host_impl.h
- +++ b/content/browser/renderer_host/render_view_host_impl.h
- @@ -110,6 +110,7 @@ class CONTENT_EXPORT RenderViewHostImpl
- SiteInstanceImpl* GetSiteInstance() override;
- bool IsRenderViewLive() override;
- void NotifyMoveOrResizeStarted() override;
- + void SetSchedulerThrottling(bool allowed) override;
- WebPreferences GetWebkitPreferences() override;
- void UpdateWebkitPreferences(const WebPreferences& prefs) override;
- void OnWebkitPreferencesChanged() override;
- diff --git a/content/common/view_messages.h b/content/common/view_messages.h
- index 19fa7ac26926231b01fe19f7adf62dd0e08edb1b..d4d3b97811a656d40884d7e4b872fdf72dfb11fa 100644
- --- a/content/common/view_messages.h
- +++ b/content/common/view_messages.h
- @@ -94,6 +94,9 @@ IPC_STRUCT_TRAITS_END()
-
- // Messages sent from the browser to the renderer.
-
- +// Whether to enable the Renderer scheduler background throttling.
- +IPC_MESSAGE_ROUTED1(ViewMsg_SetSchedulerThrottling, bool /* allowed */)
- +
- // This passes a set of webkit preferences down to the renderer.
- IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences,
- content::WebPreferences)
- diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h
- index dfd856eb481114fea9da3e26b4080c9a8473acf6..604a95a0427705eca523e91b08a136f806da68f0 100644
- --- a/content/public/browser/render_view_host.h
- +++ b/content/public/browser/render_view_host.h
- @@ -96,6 +96,9 @@ class CONTENT_EXPORT RenderViewHost : public IPC::Sender {
- // started.
- virtual void NotifyMoveOrResizeStarted() = 0;
-
- + // Disable/Enable scheduler throttling.
- + virtual void SetSchedulerThrottling(bool allowed) = 0;
- +
- // TODO(mustaq): Replace "Webkit" from the following three method names.
- //
- // Returns the current WebKit preferences. Note: WebPreferences is cached, so
- diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
- index 57447f4529917692155d1861c7658156978fa0be..2eaf980889ef9053e728dc09e76f1fcd889153b8 100644
- --- a/content/renderer/render_view_impl.cc
- +++ b/content/renderer/render_view_impl.cc
- @@ -1173,6 +1173,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
-
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
- + IPC_MESSAGE_HANDLER(ViewMsg_SetSchedulerThrottling,
- + OnSetSchedulerThrottling)
- IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
- IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
- IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
- @@ -1669,6 +1671,12 @@ bool RenderViewImpl::GetContentStateImmediately() {
- return send_content_state_immediately_;
- }
-
- +void RenderViewImpl::OnSetSchedulerThrottling(bool allowed) {
- + if (!GetWebView())
- + return;
- + GetWebView()->SetSchedulerThrottling(allowed);
- +}
- +
- void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) {
- webkit_preferences_ = prefs;
- ApplyWebPreferences(webkit_preferences_, GetWebView());
- diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
- index 79ffb7a4a0ecef7c2e0583ca06a42c7bf6146bcc..ccb6f98da708fba99579623d92f9e40607e94dda 100644
- --- a/content/renderer/render_view_impl.h
- +++ b/content/renderer/render_view_impl.h
- @@ -391,6 +391,7 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
- void OnSetHistoryOffsetAndLength(int history_offset, int history_length);
- void OnSetRendererPrefs(
- const blink::mojom::RendererPreferences& renderer_prefs);
- + void OnSetSchedulerThrottling(bool allowed);
- void OnSuppressDialogsUntilSwapOut();
- void OnUpdateTargetURLAck();
- void OnUpdateWebPreferences(const WebPreferences& prefs);
- diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h
- index baa1cec07522a23221b146165a638d3f679f9817..50f0c46c8fcbb4ee8ebb316f859f84d02d93ceda 100644
- --- a/third_party/blink/public/web/web_view.h
- +++ b/third_party/blink/public/web/web_view.h
- @@ -393,6 +393,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 94fb9863a6da4c049e45ec5966ef79d9c8e42b75..063d88779ad2ca7c4c723e2872c28d93401fcec3 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.cc
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
- @@ -3366,6 +3366,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) {
- @@ -3376,7 +3383,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 e2124434e0d8ba3416179534ababca9d3b7f1708..3881e7a9f6fb25cbec37ddce6f87bf25b0d4a400 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.h
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
- @@ -329,6 +329,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;
- @@ -681,6 +682,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
- // WebViewImpl::Close while handling an input event.
- bool debug_inside_input_handling_ = false;
-
- + bool scheduler_throttling_allowed_ = true;
- +
- FloatSize elastic_overscroll_;
-
- // If true, we send IPC messages when |preferred_size_| changes.
|