From 86bd71b89c2e0f21d893baf87a113cdada86201f Mon Sep 17 00:00:00 2001 From: Kelvin K Date: Mon, 16 Jun 2025 14:19:23 +0200 Subject: [PATCH] Fix edgecase --- .../main/java/com/futo/platformplayer/engine/V8Plugin.kt | 4 ++++ .../futo/platformplayer/views/video/FutoVideoPlayerBase.kt | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt index 462fb192..5b6ffd91 100644 --- a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt +++ b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt @@ -58,6 +58,8 @@ class V8Plugin { val httpClientAuth: ManagedHttpClient get() = _clientAuth; val httpClientOthers: Map get() = _clientOthers; + var startId: Int = 0; + fun registerHttpClient(client: JSHttpClient) { synchronized(_clientOthers) { _clientOthers.put(client.clientId, client); @@ -148,6 +150,7 @@ class V8Plugin { synchronized(_runtimeLock) { if (_runtime != null) return; + startId + 1; //V8RuntimeOptions.V8_FLAGS.setUseStrict(true); val host = V8Host.getV8Instance(); val options = host.jsRuntimeType.getRuntimeOptions(); @@ -207,6 +210,7 @@ class V8Plugin { if(isStopped) return@busy; isStopped = true; + startId = -1; //Cleanup http for(pack in _depsPackages) { diff --git a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayerBase.kt b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayerBase.kt index b0afd83f..22650adb 100644 --- a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayerBase.kt +++ b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayerBase.kt @@ -593,7 +593,6 @@ abstract class FutoVideoPlayerBase : RelativeLayout { catch(reloadRequired: ScriptReloadRequiredException) { Logger.i(TAG, "Reload required detected"); StatePlatform.instance.handleReloadRequired(reloadRequired, { - Logger.i(TAG, "ReloadRequired started reloading video"); onReloadRequired.emit(); }); } @@ -689,7 +688,9 @@ abstract class FutoVideoPlayerBase : RelativeLayout { DefaultHttpDataSource.Factory().setUserAgent(DEFAULT_USER_AGENT); if(audioSource.hasGenerate) { findViewTreeLifecycleOwner()?.lifecycle?.coroutineScope?.launch(Dispatchers.IO) { + var startId = -1; try { + startId = audioSource.getUnderlyingPlugin()?.getUnderlyingPlugin()?.startId ?: -1; val generated = audioSource.generate(); if(generated != null) { withContext(Dispatchers.Main) { @@ -705,11 +706,11 @@ abstract class FutoVideoPlayerBase : RelativeLayout { val plugin = audioSource.getUnderlyingPlugin(); if(plugin == null) return@launch; - /* + if(startId != -1 && plugin.getUnderlyingPlugin()?.startId != startId) + return@launch; StatePlatform.instance.reEnableClient(plugin.id, { onReloadRequired.emit(); }); - */ } catch(ex: Throwable) {