Fix GROUPED dedup frame skipping: run deduplication off main thread - #180
Open
disclosurez wants to merge 1 commit into
Open
Fix GROUPED dedup frame skipping: run deduplication off main thread#180disclosurez wants to merge 1 commit into
disclosurez wants to merge 1 commit into
Conversation
- Moved buildPresentedMovies/buildPresentedSeries off the main thread via .flowOn(Dispatchers.Default) on all combine calls with moviePresentationSettingsFlow / seriesPresentationSettingsFlow. - Added ASCII fast path in normalizedMovieTitle to avoid slow Normalizer.normalize() JNI call on API 25 for pure-ASCII titles. - Added ConcurrentHashMap caches for movieDisplayYear and normalizedMovieTitle results to avoid repeated regex evaluation.
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.
Problem
Enabling GROUPED (or SMART) VOD duplicate handling mode on older Fire TV devices (API 25) causes continuous 50+ frame drops during playback. The
buildPresentedMovies()/buildPresentedSeries()functions rungroupBy,flatMap, and regex-based title normalization on every browse data emission — but these ran on the main thread via the Flow combine callback, blocking the UI thread and causing Choreographer frame skips.Additionally,
normalizedMovieTitle()callsNormalizer.normalize()(a slow ICU4C JNI call) for every movie title on every emission, even for pure-ASCII IPTV titles where normalization is a no-op.Fix
Moved deduplication to background dispatcher — Added
.flowOn(Dispatchers.Default)to allcombine(moviePresentationSettingsFlow)andcombine(seriesPresentationSettingsFlow)calls in bothMovieRepositoryImplandSeriesRepositoryImpl. The combine callbacks (which callbuildPresentedMovies/buildPresentedSeries) now execute on the Default dispatcher instead of the UI thread.ASCII fast path in
normalizedMovieTitle— Added aNON_ASCII_REGEXcheck before theNormalizer.normalize()call. For pure-ASCII strings (the vast majority of IPTV movie titles), the ICU4C JNI call is skipped entirely.Caching — Added
ConcurrentHashMapcaches formovieDisplayYear()andnormalizedMovieTitle()results, keyed by input. Repeated calls with the same movie name (e.g. during screen rotations or re-browses) return instantly without recomputation.Files changed
data/.../repository/MovieRepositoryImpl.kt— flowOn on 8 combine sitesdata/.../repository/SeriesRepositoryImpl.kt— flowOn on 8 combine sitesdata/.../util/VodMovieDeduplication.kt— caching + ASCII fast path