From c6e4d06fa17ba1cc4276c0f13fa3f05e75cd5926 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 4 Apr 2021 03:42:18 +0200 Subject: [PATCH] Allow toggling chrome hardware acceleration bug workaround for people not experiencing it --- src/common/interfaces/SettingsInterface.ts | 12 ++ src/ext/lib/video-data/PlayerData.ts | 1 + src/ext/lib/video-transform/Stretcher.ts | 13 ++- src/popup/panels/SiteDetailsPanel.vue | 126 ++++++++++++++++++++- 4 files changed, 147 insertions(+), 5 deletions(-) diff --git a/src/common/interfaces/SettingsInterface.ts b/src/common/interfaces/SettingsInterface.ts index 8a06351..0806aaa 100644 --- a/src/common/interfaces/SettingsInterface.ts +++ b/src/common/interfaces/SettingsInterface.ts @@ -181,6 +181,18 @@ interface SettingsInterface { pan?: any, version?: string, preventReload?: boolean, + + // ----------------------------------------- + // ::: MITIGATIONS ::: + // ----------------------------------------- + // Settings for browser bug workarounds. + mitigations?: { + zoomLimit?: { + enabled?: boolean, + fullscreenOnly: boolean, + limit?: number, + } + } // ----------------------------------------- // ::: ACTIONS ::: // ----------------------------------------- diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts index 11e2fcb..e74f747 100644 --- a/src/ext/lib/video-data/PlayerData.ts +++ b/src/ext/lib/video-data/PlayerData.ts @@ -108,6 +108,7 @@ class PlayerData { } static isFullScreen(){ + console.info(window.innerHeight, window.screen.height, 'x', window.innerWidth, window.screen.width); return ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); } diff --git a/src/ext/lib/video-transform/Stretcher.ts b/src/ext/lib/video-transform/Stretcher.ts index 388b285..a10328e 100644 --- a/src/ext/lib/video-transform/Stretcher.ts +++ b/src/ext/lib/video-transform/Stretcher.ts @@ -271,16 +271,23 @@ squeezeFactor: ${squeezeFactor}`, '\nvideo', this.conf.video); * style attribute does). */ chromeBugMitigation(stretchFactors) { - if (BrowserDetect.anyChromium && this.conf.player?.dimensions?.fullscreen) { + console.log("limit zoom?", BrowserDetect.anyChromium, this.conf.player?.dimensions, this.settings?.active?.mitigations?.zoomLimit?.enabled); + if ( + BrowserDetect.anyChromium + && (this.conf.player?.dimensions?.fullscreen || ! + this.settings?.active?.mitigations?.zoomLimit?.fullscreenOnly) + && this.settings?.active?.mitigations?.zoomLimit?.enabled + ) { const playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height; const streamAr = this.conf.video.videoWidth / this.conf.video.videoHeight; let maxSafeAr; + let arLimitFactor = this.settings?.active?.mitigations?.zoomLimit?.limit ?? 0.997; if (playerAr >= (streamAr * 1.1)) { - maxSafeAr = (window.innerWidth * 0.997) / window.innerHeight; + maxSafeAr = (window.innerWidth * arLimitFactor) / window.innerHeight; } else if (playerAr < (streamAr * 0.95)) { - maxSafeAr = window.innerWidth / (window.innerHeight * 0.997); + maxSafeAr = window.innerWidth / (window.innerHeight * arLimitFactor); } else { // in some cases, we tolerate minor stretch to avoid tiny black bars return; diff --git a/src/popup/panels/SiteDetailsPanel.vue b/src/popup/panels/SiteDetailsPanel.vue index 0e5d5fd..3547ae8 100644 --- a/src/popup/panels/SiteDetailsPanel.vue +++ b/src/popup/panels/SiteDetailsPanel.vue @@ -1,5 +1,5 @@