From bbbf152c62337ecf97f4cdc62ccb76aa764e9817 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Tue, 2 Nov 2021 08:15:49 +1000 Subject: [PATCH] Fix performance on MacOS, Chrome & external screen (#2104) * Fix performance on MacOS, Chrome & external screen * Undo dev logging, tidy up --- src/popup/scss/misc.scss | 14 ++++++++++++++ src/popup/services/services.module.ts | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/popup/scss/misc.scss b/src/popup/scss/misc.scss index 6782ea0e4b..e61dc028dd 100644 --- a/src/popup/scss/misc.scss +++ b/src/popup/scss/misc.scss @@ -367,3 +367,17 @@ select option { background-color: darken(themed('inputBackgroundColor'), +1); } } + +// Workaround for slow performance on external monitors on Chrome + MacOS +// See: https://bugs.chromium.org/p/chromium/issues/detail?id=971701#c64 +@keyframes redraw { + 0% { + opacity: 0.99; + } + 100% { + opacity: 1; + } +} +html.force_redraw { + animation: redraw 1s linear infinite; +} diff --git a/src/popup/services/services.module.ts b/src/popup/services/services.module.ts index 1e6248f61c..4ca02093d4 100644 --- a/src/popup/services/services.module.ts +++ b/src/popup/services/services.module.ts @@ -76,9 +76,9 @@ const isPrivateMode = BrowserApi.getBackgroundPage() == null; const stateService = new StateService(); const messagingService = new BrowserMessagingService(); +const logService = getBgService('logService')(); const searchService = isPrivateMode ? null : new PopupSearchService(getBgService('searchService')(), - getBgService('cipherService')(), getBgService('consoleLogService')(), - getBgService('i18nService')()); + getBgService('cipherService')(), logService, getBgService('i18nService')()); export function initFactory(platformUtilsService: PlatformUtilsService, i18nService: I18nService, storageService: StorageService, popupUtilsService: PopupUtilsService): Function { @@ -109,6 +109,19 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ } }); htmlEl.classList.add('locale_' + i18nService.translationLocale); + + // Workaround for slow performance on external monitors on Chrome + MacOS + // See: https://bugs.chromium.org/p/chromium/issues/detail?id=971701#c64 + if (platformUtilsService.isChrome() && + navigator.platform.indexOf('Mac') > -1 && + popupUtilsService.inPopup(window) && + (window.screenLeft < 0 || + window.screenTop < 0 || + window.screenLeft > window.screen.width || + window.screenTop > window.screen.height)) { + htmlEl.classList.add('force_redraw'); + logService.info('Force redraw is on'); + } } }; }