From 93eb67ca4945d95a87e5fda3131469232fd0581b Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 4 Apr 2021 23:19:43 +0200 Subject: [PATCH] Prevent recursing --- src/ext/lib/video-transform/Resizer.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ext/lib/video-transform/Resizer.ts b/src/ext/lib/video-transform/Resizer.ts index 86f88e1..3a88934 100644 --- a/src/ext/lib/video-transform/Resizer.ts +++ b/src/ext/lib/video-transform/Resizer.ts @@ -527,6 +527,7 @@ class Resizer { return mode === 'height' ? heightFactor : widthFactor; } + private _computeOffsetsRecursionGuard: boolean = false; computeOffsets(stretchFactors: VideoDimensions){ this.logger.log('info', 'debug', "[Resizer::computeOffsets] video will be aligned to ", this.settings.active.sites['@global'].videoAlignment); @@ -549,10 +550,6 @@ class Resizer { const wdiff = this.conf.player.dimensions.width - realVideoWidth; const hdiff = this.conf.player.dimensions.height - realVideoHeight; - if (wdiff < 0 && hdiff < 0 && this.zoom.scale > 1) { - this.conf.resizer.restore(); - } - const wdiffAfterZoom = realVideoWidth * stretchFactors.xFactor - this.conf.player.dimensions.width; const hdiffAfterZoom = realVideoHeight * stretchFactors.yFactor - this.conf.player.dimensions.height; @@ -614,8 +611,15 @@ class Resizer { `Video seems to be both wider and taller (or shorter and narrower) than player element at the same time. This is super duper not supposed to happen.\n\n`, `Player element needs to be checked.` ) - if (this.conf.player.checkPlayerSizeChange()) { - this.conf.player.onPlayerDimensionsChanged(); + + // sometimes this appears to randomly recurse. + // There seems to be no way to reproduce it. + if (! this._computeOffsetsRecursionGuard) { + this._computeOffsetsRecursionGuard = true; + if (this.conf.player.checkPlayerSizeChange()) { + this.conf.player.onPlayerDimensionsChanged(); + } + this._computeOffsetsRecursionGuard = false; } }