From 736ab0f51c81269f6bf804465062595b1003f336 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 10 Mar 2026 18:28:10 +0100 Subject: [PATCH] chore: optimize IPTV performance and fix navigation Loop - Revert aggressive caching in XtreamService (use forceCache + 1h stale) - Adjust HLS.js buffers (60s-120s) for stream stability - Fix desktop navigation loop in PlaylistSelectionScreen - Fix receive timeouts (revert to 30s/60s) --- lib/features/iptv/services/xtream_service.dart | 10 +++++----- web/player_lite.html | 8 ++++---- web/player_mobile.html | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/features/iptv/services/xtream_service.dart b/lib/features/iptv/services/xtream_service.dart index 6ac75fb..144a272 100644 --- a/lib/features/iptv/services/xtream_service.dart +++ b/lib/features/iptv/services/xtream_service.dart @@ -18,9 +18,9 @@ class XtreamService { XtreamService() { _dio = Dio( BaseOptions( - connectTimeout: const Duration(seconds: 300), - receiveTimeout: const Duration(seconds: 300), - sendTimeout: const Duration(seconds: 300), + connectTimeout: const Duration(seconds: 30), + receiveTimeout: const Duration(seconds: 60), + sendTimeout: const Duration(seconds: 60), ), ); @@ -28,8 +28,8 @@ class XtreamService { // Use MemCacheStore on Web to avoid path errors _cacheOptions = CacheOptions( store: kIsWeb ? MemCacheStore() : HiveCacheStore('./cache'), - policy: CachePolicy.refresh, // Allow refresh if stale - maxStale: const Duration(minutes: 15), // Reduced from 1h to 15m for better sync + policy: CachePolicy.forceCache, // Prioritize local cache + maxStale: const Duration(hours: 1), // Increase to 1h for stability priority: CachePriority.high, ); diff --git a/web/player_lite.html b/web/player_lite.html index 242291c..2c80cd7 100644 --- a/web/player_lite.html +++ b/web/player_lite.html @@ -243,11 +243,11 @@ } const hls = new Hls({ - maxBufferLength: 30, // 30s is plenty for desktop stability - maxMaxBufferLength: 60, + maxBufferLength: 60, // Increased for better stability + maxMaxBufferLength: 120, enableWorker: true, - liveSyncDurationCount: 3, - liveMaxLatencyDurationCount: 10, + liveSyncDurationCount: 5, // More stable sync + liveMaxLatencyDurationCount: 15, lowLatencyMode: true }); diff --git a/web/player_mobile.html b/web/player_mobile.html index 425c868..dc42b68 100644 --- a/web/player_mobile.html +++ b/web/player_mobile.html @@ -229,12 +229,12 @@ if (isHLS && Hls.isSupported()) { log('Using Hls.js optimized for mobile'); const hls = new Hls({ - maxBufferLength: 30, - maxMaxBufferLength: 60, - liveSyncDurationCount: 3, - liveMaxLatencyDurationCount: 10, + maxBufferLength: 60, // More buffer for mobile stability + maxMaxBufferLength: 120, + liveSyncDurationCount: 5, + liveMaxLatencyDurationCount: 15, enableWorker: true, - lowLatencyMode: true + lowLatencyMode: false // Disable low latency for continuity }); hls.loadSource(streamUrl); hls.attachMedia(video);