fix: improve IPTV playlist concurrency safety and XMLTV parsing relia…#316
Open
saidai-bhuvanesh wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This Pull Request introduces critical performance and reliability improvements to the IPTV playlist loading and EPG XMLTV parsing engine in ARVIO. The changes address a silent crash condition during concurrent playlist loads and a complete bypass of backslash escape sanitization during EPG parsing.
Key Improvements
1. Concurrency Fix for Playlist Loading
Collections.synchronizedList. As each playlist finished,runCatching { onChannelsReady(aggregatedChannels.toList()) }copied the list. However, iterating on a synchronized list is not thread-safe and threw aConcurrentModificationExceptionwhen another thread added channels concurrently. This silenced the callback and prevented the UI from receiving channel updates..toList()copy operation in an explicitsynchronized(aggregatedChannels)block inIptvRepository.kt.2. Optimized Bulk Sanitization for EPG XMLTV Files
BackslashEscapeSanitizingInputStream(designed to filter JSON-style backslashes to prevent XML parser crashes) only overrode the single-byteread(). Because XML Pull/SAX parsers read in blocks, this filter was completely bypassed, causing crashes on malformed feeds.read(b: ByteArray, off: Int, len: Int)to perform in-place sanitization directly on the byte buffer in a single pass. A lookahead mechanism handles split backslash boundaries cleanly.3. Unit Test Verification
IptvRepositoryOptimizationTest.ktverifying:Verification & Test Results
Both main build variants compile successfully, and the entire test suite passes without regressions:
BUILD SUCCESSFUL(42 tasks executed/up-to-date)BUILD SUCCESSFUL(42 tasks executed/up-to-date)BUILD SUCCESSFUL(all tests passed, including the new optimization test suite)