mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* chore: bump chromium in DEPS to 140.0.7309.0 * 6762172: Replace MSG_ROUTING_NONE with IPC::mojom::kRoutingIdNone. Refs https://chromium-review.googlesource.com/c/chromium/src/+/6762172 * 6759543: [exit-time-destructors] Exclude target with warnings Refs https://chromium-review.googlesource.com/c/chromium/src/+/6759543 * 6765167: Split PreconnectManager into interface and implementation. Refs https://chromium-review.googlesource.com/c/chromium/src/+/6765167 * 6766775: [media] Clarify coded and visible size in FrameResources Refs https://chromium-review.googlesource.com/c/chromium/src/+/6766775 * 6760878: Move PreconnectRequest to //content/public Refs https://chromium-review.googlesource.com/c/chromium/src/+/6760878 * 6718973: Implement media playback trust check for the video PiP overlay window Refs https://chromium-review.googlesource.com/c/chromium/src/+/6718973 * chore: add missing include of <iterator> in ada * chore: update patches * chore: node gen-libc++-filenames.js * 6759633: [media] Use format from shared image in FrameResources Refs https://chromium-review.googlesource.com/c/chromium/src/+/6759633 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
178 lines
8.9 KiB
Diff
178 lines
8.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
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/navigation_controller_impl_unittest.cc b/content/browser/renderer_host/navigation_controller_impl_unittest.cc
|
|
index 3b996644e4bdeed5128d6cfb8b5f4fb9ddf4a00f..3c72cd28acbcc57aa086953942175cf33dfbd28a 100644
|
|
--- a/content/browser/renderer_host/navigation_controller_impl_unittest.cc
|
|
+++ b/content/browser/renderer_host/navigation_controller_impl_unittest.cc
|
|
@@ -167,6 +167,12 @@ class MockPageBroadcast : public blink::mojom::PageBroadcast {
|
|
(network::mojom::AttributionSupport support),
|
|
(override));
|
|
|
|
+ MOCK_METHOD(
|
|
+ void,
|
|
+ SetSchedulerThrottling,
|
|
+ (bool allowed),
|
|
+ (override));
|
|
+
|
|
mojo::PendingAssociatedRemote<blink::mojom::PageBroadcast> GetRemote() {
|
|
return receiver_.BindNewEndpointAndPassDedicatedRemote();
|
|
}
|
|
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
|
|
index 04f7f6c52a28f21c621a1932677da380ff0c941c..08fdd256ae7a6446b9824b479c4c39659a2d6426 100644
|
|
--- a/content/browser/renderer_host/render_view_host_impl.cc
|
|
+++ b/content/browser/renderer_host/render_view_host_impl.cc
|
|
@@ -764,6 +764,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 7944fe64e0da112fc670358b75506bb199bb5e4a..0e3c16c6af2a078943e9f39808134ab20c115e99 100644
|
|
--- a/content/browser/renderer_host/render_view_host_impl.h
|
|
+++ b/content/browser/renderer_host/render_view_host_impl.h
|
|
@@ -136,6 +136,7 @@ class CONTENT_EXPORT RenderViewHostImpl
|
|
void EnablePreferredSizeMode() 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/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
|
index 9b0bcaab04af3f13aca061604fe1be4daa159a35..c912ad0a9cee55b2da316eba71e4e741365fda1b 100644
|
|
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
|
|
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
|
@@ -580,8 +580,8 @@ void RenderWidgetHostViewAura::ShowImpl(PageVisibilityState page_visibility) {
|
|
// OnShowWithPageVisibility will not call NotifyHostAndDelegateOnWasShown,
|
|
// which updates `visibility_`, unless the host is hidden. Make sure no update
|
|
// is needed.
|
|
- CHECK(host_->is_hidden() || visibility_ == Visibility::VISIBLE);
|
|
- OnShowWithPageVisibility(page_visibility);
|
|
+ if (host_->is_hidden() || visibility_ == Visibility::VISIBLE)
|
|
+ OnShowWithPageVisibility(page_visibility);
|
|
}
|
|
|
|
void RenderWidgetHostViewAura::EnsurePlatformVisibility(
|
|
diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h
|
|
index 20ca763ff7f55e8176b77349b41917b11e051ae6..a50c122064b5f0092f57e3d508fb19389b72203b 100644
|
|
--- a/content/public/browser/render_view_host.h
|
|
+++ b/content/public/browser/render_view_host.h
|
|
@@ -75,6 +75,9 @@ class CONTENT_EXPORT RenderViewHost {
|
|
virtual void WriteIntoTrace(
|
|
perfetto::TracedProto<TraceProto> context) const = 0;
|
|
|
|
+ // Disable/Enable scheduler throttling.
|
|
+ virtual void SetSchedulerThrottling(bool allowed) {}
|
|
+
|
|
private:
|
|
// This interface should only be implemented inside content.
|
|
friend class RenderViewHostImpl;
|
|
diff --git a/content/test/test_page_broadcast.h b/content/test/test_page_broadcast.h
|
|
index 3f4fdfcdf2f701a394e182bd61baf226338ef7f8..f2faa1225e8ca6abb190e6f7a0775545fa3f785d 100644
|
|
--- a/content/test/test_page_broadcast.h
|
|
+++ b/content/test/test_page_broadcast.h
|
|
@@ -51,6 +51,7 @@ class TestPageBroadcast : public blink::mojom::PageBroadcast {
|
|
network::mojom::AttributionSupport support) override;
|
|
void UpdateColorProviders(
|
|
const blink::ColorProviderColorMaps& color_provider_colors) override;
|
|
+ void SetSchedulerThrottling(bool allowed) override {}
|
|
|
|
mojo::AssociatedReceiver<blink::mojom::PageBroadcast> receiver_;
|
|
};
|
|
diff --git a/third_party/blink/public/mojom/page/page.mojom b/third_party/blink/public/mojom/page/page.mojom
|
|
index b6a4e3609af1f090f1f845d77fa0589e5b178d8a..989b2cf76ce88614b57e75ce2fcace101225f43e 100644
|
|
--- a/third_party/blink/public/mojom/page/page.mojom
|
|
+++ b/third_party/blink/public/mojom/page/page.mojom
|
|
@@ -175,4 +175,7 @@ interface PageBroadcast {
|
|
// 2. The ColorProvider associated with the WebContents changes as a result
|
|
// of theme changes.
|
|
UpdateColorProviders(ColorProviderColorMaps color_provider_colors);
|
|
+
|
|
+ // 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 c8d27cfee8ef3fe244291f4667b59df1037c359b..92ed53a689991ec8eca9572bf2f7a212acfc4a38 100644
|
|
--- a/third_party/blink/public/web/web_view.h
|
|
+++ b/third_party/blink/public/web/web_view.h
|
|
@@ -360,6 +360,7 @@ class BLINK_EXPORT WebView {
|
|
// Scheduling -----------------------------------------------------------
|
|
|
|
virtual PageScheduler* Scheduler() const = 0;
|
|
+ virtual void SetSchedulerThrottling(bool allowed) {}
|
|
|
|
// 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 70dad492f1a4f056d2b706a09721090b2752ad8b..f2a332453e3bd421ff563a0b11c1aae5ef185db2 100644
|
|
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
@@ -2493,6 +2493,10 @@ void WebViewImpl::SetPageLifecycleStateInternal(
|
|
TRACE_EVENT2("navigation", "WebViewImpl::SetPageLifecycleStateInternal",
|
|
"old_state", old_state, "new_state", new_state);
|
|
|
|
+ // If backgroundThrottling is disabled, the page is always visible.
|
|
+ if (!scheduler_throttling_allowed_)
|
|
+ new_state->visibility = mojom::blink::PageVisibilityState::kVisible;
|
|
+
|
|
bool storing_in_bfcache = new_state->is_in_back_forward_cache &&
|
|
!old_state->is_in_back_forward_cache;
|
|
bool restoring_from_bfcache = !new_state->is_in_back_forward_cache &&
|
|
@@ -3990,10 +3994,23 @@ 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);
|
|
+}
|
|
+
|
|
void WebViewImpl::SetVisibilityState(
|
|
mojom::blink::PageVisibilityState visibility_state,
|
|
bool is_initial_state) {
|
|
DCHECK(GetPage());
|
|
+
|
|
+ if (!scheduler_throttling_allowed_) {
|
|
+ GetPage()->SetVisibilityState(mojom::blink::PageVisibilityState::kVisible, is_initial_state);
|
|
+ GetPage()->GetPageScheduler()->SetPageVisible(true);
|
|
+ return;
|
|
+ }
|
|
+
|
|
GetPage()->SetVisibilityState(visibility_state, is_initial_state);
|
|
// Do not throttle if the page should be painting.
|
|
bool is_visible =
|
|
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 5c8a5d7f9b675a460740643fc26d778a08ef7112..2ebae3e0a5b76eb9551d286af1ed64e1e58b9de4 100644
|
|
--- a/third_party/blink/renderer/core/exported/web_view_impl.h
|
|
+++ b/third_party/blink/renderer/core/exported/web_view_impl.h
|
|
@@ -445,6 +445,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;
|
|
@@ -935,6 +936,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;
|