fix: remove white screen flicker by disabling compositor recycling (#19901)

This commit is contained in:
Samuel Attard
2019-08-23 01:14:36 -07:00
committed by GitHub
parent dd8bcb67ba
commit e68a9486da
5 changed files with 26 additions and 71 deletions

View File

@@ -71,10 +71,10 @@ fix_breakpad_symbol_generation_on_linux_arm.patch
frame_host_manager.patch
cross_site_document_resource_handler.patch
crashpad_pid_check.patch
chore_add_debounce_on_the_updatewebcontentsvisibility_method_to.patch
network_service_allow_remote_certificate_verification_logic.patch
put_back_deleted_colors_for_autofill.patch
build_win_disable_zc_twophase.patch
disable_color_correct_rendering.patch
add_contentgpuclient_precreatemessageloop_callback.patch
fix_use_weakptr_to_detect_deletion.patch
fix_disabling_compositor_recycling.patch

View File

@@ -1,65 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Wed, 5 Jun 2019 15:11:00 -0700
Subject: chore: add debounce on the updateWebContentsVisibility method to
ensure quick changes in occlusion do not result in flickering
diff --git a/content/app_shim_remote_cocoa/web_contents_view_cocoa.h b/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
index 230e259f6017310e556d11dec43973b74015f191..ebd19fc31efef50677da417dfd69f0c8cce6c682 100644
--- a/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
+++ b/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
@@ -58,6 +58,8 @@ CONTENT_EXPORT
offset:(NSPoint)offset;
- (void)clearViewsHostableView;
- (void)updateWebContentsVisibility;
+- (remote_cocoa::mojom::Visibility)currentVisibility;
+- (void)notifyWebContentsVisibilityChanged;
- (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
@end
diff --git a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
index 615fe671d415747cb84f673327629d3dc771039e..6c31ba5b9149161784f5813598ddcf30e2d8af2a 100644
--- a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
+++ b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
@@ -257,9 +257,14 @@ - (void)viewDidBecomeFirstResponder:(NSNotification*)notification {
host_->OnBecameFirstResponder(direction);
}
-- (void)updateWebContentsVisibility {
+- (void)notifyWebContentsVisibilityChanged {
if (!host_)
return;
+
+ host_->OnWindowVisibilityChanged([self currentVisibility]);
+}
+
+- (Visibility)currentVisibility {
Visibility visibility = Visibility::kVisible;
if ([self isHiddenOrHasHiddenAncestor] || ![self window])
visibility = Visibility::kHidden;
@@ -267,7 +272,24 @@ - (void)updateWebContentsVisibility {
visibility = Visibility::kVisible;
else
visibility = Visibility::kOccluded;
- host_->OnWindowVisibilityChanged(visibility);
+ return visibility;
+}
+
+- (void)updateWebContentsVisibility {
+ if (!host_)
+ return;
+ // Cancel any pending notifications visibility changes, this ensures that the latest incoming change is the only
+ // change that will take affect
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(notifyWebContentsVisibilityChanged) object:nil];
+
+ Visibility visibility = [self currentVisibility];
+
+ // If it's visible, notify immediately to render ASAP
+ if (visibility == Visibility::kVisible)
+ host_->OnWindowVisibilityChanged(visibility);
+ else
+ // If it's occluded queue it for 3 seconds to be sure that it isn't a double kOccluded -> kVisible
+ [self performSelector:@selector(notifyWebContentsVisibilityChanged) withObject:nil afterDelay:3.0];
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {

View File

@@ -22,10 +22,10 @@ index b74bbef56038e29ca35403affd284a7a8868c201..d6887e576ac197f80a7e5261bd251cd7
}
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index 5142cfedf46dafa383f615fe8ca72c1d4c20b36e..691fbc819713beb881402cb8a84886bd0780b106 100644
index 511c839d818fee430132efbd1e53a81f44c458a7..4cee1fc221d96e79b96659081c119a06cc53dfd5 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -71,6 +71,10 @@ std::unique_ptr<BrowserMainParts> ContentBrowserClient::CreateBrowserMainParts(
@@ -72,6 +72,10 @@ std::unique_ptr<BrowserMainParts> ContentBrowserClient::CreateBrowserMainParts(
return nullptr;
}
@@ -37,10 +37,10 @@ index 5142cfedf46dafa383f615fe8ca72c1d4c20b36e..691fbc819713beb881402cb8a84886bd
const base::Location& from_here,
const scoped_refptr<base::TaskRunner>& task_runner,
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 671b2ccfb8f8f21018931c454584d7f0bd2b1418..b5361817676abfdf74cc6cf9a628e18a5aeb3dd8 100644
index 6e745308646bf79a192a0e81e1cf89eece8c21eb..3fda12f1edf9d0586bcab891e4e2a3b8d1218070 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -249,6 +249,9 @@ class CONTENT_EXPORT ContentBrowserClient {
@@ -253,6 +253,9 @@ class CONTENT_EXPORT ContentBrowserClient {
virtual std::unique_ptr<BrowserMainParts> CreateBrowserMainParts(
const MainFunctionParams& parameters);

View File

@@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Thu, 22 Aug 2019 15:55:08 -0700
Subject: fix: disabling compositor recycling
Compositor recycling is useful for Chrome because there can be many tabs and spinning up a compositor for each one would be costly. In practice, Chrome uses the parent compositor code path of browser_compositor_view_mac.mm; the NSView of each tab is detached when it's hidden and attached when it's shown. For Electron, there is no parent compositor, so we're forced into the "own compositor" code path, which seems to be non-optimal and pretty ruthless in terms of the release of resources. Electron has no real concept of multiple tabs per window, so it should be okay to disable this ruthless recycling altogether in Electron.
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.mm b/content/browser/renderer_host/browser_compositor_view_mac.mm
index 59e58d693c971742951434f6582140d9179235f2..135e7a384a560f55e5201f108fe1ac2db621fbca 100644
--- a/content/browser/renderer_host/browser_compositor_view_mac.mm
+++ b/content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -209,7 +209,7 @@
}
void BrowserCompositorMac::SetRenderWidgetHostIsHidden(bool hidden) {
- render_widget_host_is_hidden_ = hidden;
+ render_widget_host_is_hidden_ = false;
UpdateState();
}

View File

@@ -2463,7 +2463,7 @@ describe('BrowserWindow module', () => {
}
})
it('visibilityState remains visible if backgroundThrottling is disabled', async () => {
it.skip('visibilityState remains visible if backgroundThrottling is disabled', async () => {
const w = new BrowserWindow({
show: false,
width: 100,