From 9338b36b8ed89257221bce5bb94f0bf8a2476196 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 21:12:16 +0300 Subject: [PATCH 1/4] Clear JavascriptSubtitlesOctopus when an error occurs --- src/plugins/htmlVideoPlayer/plugin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 611240be3e..cf477bfd9d 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1062,6 +1062,9 @@ function tryRemoveElement(elem) { workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`, legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`, onError() { + // HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs + htmlVideoPlayer.#currentSubtitlesOctopus = null; + onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); }, timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000, From 9f6fdfdd7215c724385f8b0ac813787e8e84025a Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 21:30:59 +0300 Subject: [PATCH 2/4] Destroy the player after destroying JavascriptSubtitlesOctopus --- src/plugins/htmlVideoPlayer/plugin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index cf477bfd9d..f1a0f427d6 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -675,14 +675,14 @@ function tryRemoveElement(elem) { } onEndedInternal(this, elem, this.onError); - - if (destroyPlayer) { - this.destroy(); - } } this.destroyCustomTrack(elem); + if (destroyPlayer) { + this.destroy(); + } + return Promise.resolve(); } From 50880983cc2e561ff1fa901559bda1b49ea15eef Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 22:20:03 +0300 Subject: [PATCH 3/4] Give JavascriptSubtitlesOctopus time to dispose itself --- src/plugins/htmlVideoPlayer/plugin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index f1a0f427d6..eeef1d5181 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1065,7 +1065,10 @@ function tryRemoveElement(elem) { // HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs htmlVideoPlayer.#currentSubtitlesOctopus = null; - onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + // HACK: Give JavascriptSubtitlesOctopus time to dispose itself + setTimeout(() => { + onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + }, 0); }, timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000, From a536f2acac7067d0a22b8be22f4c85b2cbc7c344 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 21 Sep 2021 22:26:09 +0300 Subject: [PATCH 4/4] Resolve show promise --- src/components/appRouter.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index e40875089c..5a89deca54 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -44,13 +44,7 @@ class AppRouter { }, 0); }); - document.addEventListener('viewshow', () => { - const resolve = this.resolveOnNextShow; - if (resolve) { - this.resolveOnNextShow = null; - resolve(); - } - }); + document.addEventListener('viewshow', () => this.onViewShow()); this.baseRoute = window.location.href.split('?')[0].replace(this.getRequestFile(), ''); // support hashbang @@ -417,6 +411,14 @@ class AppRouter { }); } + onViewShow() { + const resolve = this.resolveOnNextShow; + if (resolve) { + this.resolveOnNextShow = null; + resolve(); + } + } + onForcedLogoutMessageTimeout() { const msg = this.forcedLogoutMsg; this.forcedLogoutMsg = null; @@ -638,7 +640,11 @@ class AppRouter { const ignore = route.dummyRoute === true || this.previousRoute.dummyRoute === true; this.previousRoute = route; - if (ignore) return; + if (ignore) { + // Resolve 'show' promise + this.onViewShow(); + return; + } this.handleRoute(ctx, next, route); };