From cb5218e52d8e7b0283fad7756e5319e15a549e1d Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Mon, 8 Feb 2021 20:44:34 +0100 Subject: [PATCH] Only allow one instance of offset validation watcher per video element --- src/ext/lib/video-data/VideoData.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 486490d..8643422 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -25,6 +25,8 @@ class VideoData { this.videoLoaded = false; this.videoDimensionsLoaded = true; + this.validationId = null; + this.dimensions = { width: this.video.offsetWidth, height: this.video.offsetHeight, @@ -276,8 +278,14 @@ class VideoData { } } + /** + * Starts fallback change detection (validates whether currently applied settings are correct) + */ async fallbackChangeDetection() { - while (!this.destroyed && !this.invalid) { + const validationId = Date.now(); + this.validationId = validationId; + + while (!this.destroyed && !this.invalid && this.validationId === validationId) { await this.sleep(500); this.doPeriodicFallbackChangeDetectionCheck(); }