Fix edgecase

This commit is contained in:
Kelvin K 2025-06-16 14:19:23 +02:00
commit 86bd71b89c
2 changed files with 8 additions and 3 deletions

View file

@ -58,6 +58,8 @@ class V8Plugin {
val httpClientAuth: ManagedHttpClient get() = _clientAuth;
val httpClientOthers: Map<String, JSHttpClient> 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) {

View file

@ -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) {