123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- 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 195b0f2da8a08f59566bb6306ccbec94b684d613..8d04d13574374a2cf2b09c2dd30b6b9f07b4ac84 100644
- --- a/content/browser/renderer_host/render_view_host_impl.cc
- +++ b/content/browser/renderer_host/render_view_host_impl.cc
- @@ -433,6 +433,10 @@ void RenderViewHostImpl::SetBackgroundOpaque(bool opaque) {
- Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), 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 4311c3406cc8a3e2af505df182c890e4de6e5ea3..15daed8fd4071926c9fa7bf3aa00789b0dae0928 100644
- --- a/content/browser/renderer_host/render_view_host_impl.h
- +++ b/content/browser/renderer_host/render_view_host_impl.h
- @@ -108,6 +108,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 accb317ce091177766a8c49054b3e274b57871d8..8e0c40cbb98e02849c4c9dffc714eb48fbb40d57 100644
- --- a/content/common/view_messages.h
- +++ b/content/common/view_messages.h
- @@ -109,6 +109,9 @@ IPC_STRUCT_TRAITS_END()
- // Make the RenderWidget background transparent or opaque.
- IPC_MESSAGE_ROUTED1(ViewMsg_SetBackgroundOpaque, bool /* opaque */)
-
- +// 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 95679ab2915ad496ca0018aa13874b84eb11d7fd..c278e0fc072409677beafc7f252ebcf6002f16d4 100644
- --- a/content/public/browser/render_view_host.h
- +++ b/content/public/browser/render_view_host.h
- @@ -99,6 +99,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 37ac96bb7d42fe4caeb31861875219079d986982..d4b3d0f71ea6bc6aa9b927f32ee09eb9732c46c7 100644
- --- a/content/renderer/render_view_impl.cc
- +++ b/content/renderer/render_view_impl.cc
- @@ -1210,6 +1210,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
- IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
- IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
- IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
- + IPC_MESSAGE_HANDLER(ViewMsg_SetSchedulerThrottling,
- + OnSetSchedulerThrottling)
- IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
- IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
- IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
- @@ -1800,6 +1802,12 @@ void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
- webview()->SetPageScaleFactor(page_scale_factor);
- }
-
- +void RenderViewImpl::OnSetSchedulerThrottling(bool allowed) {
- + if (!webview())
- + return;
- + webview()->SetSchedulerThrottling(allowed);
- +}
- +
- void RenderViewImpl::ApplyPageVisibilityState(
- PageVisibilityState visibility_state,
- bool initial_setting) {
- diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
- index a6768059fb7e91115f4659f236f096d264977408..a5954b581e06f78d364f4525f1550f7f13c836ec 100644
- --- a/content/renderer/render_view_impl.h
- +++ b/content/renderer/render_view_impl.h
- @@ -452,6 +452,7 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
- void OnSetInitialFocus(bool reverse);
- 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 dc04ef3eb3a1a56d932a22ffce7b71bb60786f7a..3e7d605d7a0f884299e441d954877c03436aa618 100644
- --- a/third_party/blink/public/web/web_view.h
- +++ b/third_party/blink/public/web/web_view.h
- @@ -399,6 +399,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 34ff617acbd75b2d431aef194cceff651aadc24f..b681d16f2bf1aa9151d455f1a6d9ebb55adeae7b 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.cc
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
- @@ -3326,12 +3326,20 @@ PageScheduler* WebViewImpl::Scheduler() const {
- return GetPage()->GetPageScheduler();
- }
-
- +void WebViewImpl::SetSchedulerThrottling(bool allowed) {
- + DCHECK(GetPage());
- + scheduler_throttling_allowed_ = allowed;
- + GetPage()->GetPageScheduler()->SetPageVisible(allowed ?
- + (GetVisibilityState() == PageVisibilityState::kVisible) : true);
- +}
- +
- void WebViewImpl::SetVisibilityState(PageVisibilityState visibility_state,
- bool is_initial_state) {
- DCHECK(GetPage());
- GetPage()->SetVisibilityState(visibility_state, is_initial_state);
- - GetPage()->GetPageScheduler()->SetPageVisible(visibility_state ==
- - PageVisibilityState::kVisible);
- + GetPage()->GetPageScheduler()->SetPageVisible(
- + scheduler_throttling_allowed_ ?
- + (visibility_state == PageVisibilityState::kVisible) : true);
- }
-
- 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 3154dbd08dc8aa0386c6259afdec084570822a9e..b9f6ed110e4527a9a05074c31cc89982edaae4f2 100644
- --- a/third_party/blink/renderer/core/exported/web_view_impl.h
- +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
- @@ -306,6 +306,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
- LocalDOMWindow* PagePopupWindow() const;
-
- PageScheduler* Scheduler() const override;
- + void SetSchedulerThrottling(bool allowed) override;
- void SetVisibilityState(PageVisibilityState visibility_state,
- bool is_initial_state) override;
- PageVisibilityState GetVisibilityState() override;
- @@ -680,6 +681,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_;
-
- Persistent<EventListener> popup_mouse_wheel_event_listener_;
|