# TiviLux Native v0.4.37 / Build 53 — revised performance release

APK name: TiviLux-Native-v0.4.37.apk
Source ZIP: TiviLux-Native-v0.4.37-B53-Playback-Performance.zip
This replaces the earlier conservative v0.4.37 source package in this conversation.
Build with the same application ID and signing certificate as the existing APK Builder.
Publish the APK before root latest.json. Its sha256 remains blank because no final APK
was built or hashed here. Historical manifests are retained unchanged.

## Changes against golden v0.4.36 / Build 52
1. ui/TiviLuxApp.kt: stop and clear shared Live/VOD players whenever their playback
   mode is inactive instead of merely pausing them. This ends inactive stream loading
   and releases prepared media/decoder resources. Live guide-to-fullscreen remains one
   continuously active shared player. Independent MultiView players remain intact.
2. ui/components/LuxComponents.kt: device-aware sample-buffer byte targets, size-aware
   load control, and a five-second exact VOD back buffer replace time-prioritized loading
   and the 30-second/keyframe-retained VOD back buffer. All preset startup/rebuffer and
   forward-duration thresholds remain unchanged. Also retains the first revision's
   URL/player-scoped recovery cancellation and redundant-prepare guard.
3. data/PlaybackBufferBudget.java (new): targets use the Android memory class and
   low-RAM flag. Live: heap/16 MiB, bounded to 8–24 MiB (8–12 low-RAM). VOD: heap/4,
   bounded to 24–96 MiB (24–32 low-RAM). Each MultiView player uses the live target.
   These targets are NOT hard limits on total player/process/decoder memory.
4. AppViewModel.kt: memoize the filtered display catalog per content type by published
   list identity and content-visibility revision. Refresh/profile changes and logout
   invalidate cached results. Catalog ordering, contents and visibility rules are unchanged.
5. data/VisibleCatalogCache.java (new): one immutable result per published catalog,
   O(1) identity/revision checks on a cache hit, no repeated filtering or list allocation.
6. ui/screens/PlayerScreen.kt: retains the first revision's hidden-VOD-HUD polling
   suspension. Continue Watching's independent save/completion callbacks stay unchanged.
7. app/build.gradle.kts: versionCode 53 / versionName 0.4.37 only.
8. latest.json: exact required APK URL, accurate concise notes and empty APK hash.

Kotlin/Java source paths above are relative to app/src/main/java/tv/tivilux/nativeplayer/.

## Verification
The two new production Java classes compiled using Java 17's jdk.compiler module.
verification/PerformancePolicyCheck.java passed cache hit, source replacement, visibility
revision, empty catalog, order/completeness, clear, immutability and buffer-budget bounds.
A deterministic 50,000-item / 300-read case performed 50,000 filtering calls instead of
the uncached path's 15,000,000. This is an operation-count result, NOT measured app FPS,
startup time, or a claim that the app is 300 times faster.

Run the standalone checks from project root:
  java -m jdk.compiler/com.sun.tools.javac.Main -d /tmp/tivilux-check \
    app/src/main/java/tv/tivilux/nativeplayer/data/VisibleCatalogCache.java \
    app/src/main/java/tv/tivilux/nativeplayer/data/PlaybackBufferBudget.java \
    verification/PerformancePolicyCheck.java
  java -cp /tmp/tivilux-check PerformancePolicyCheck

Android build attempt: gradle --offline :app:assembleRelease
Blocked before compilation: gradle: command not found. No Android SDK/Gradle is installed;
the golden project includes no wrapper. Full Android/Kotlin build and device playback
are unverified. No compiled APK is included. Use the existing APK Builder workflow.

All 151 golden files are retained. Changed existing files are exactly AppViewModel.kt,
ui/TiviLuxApp.kt, ui/components/LuxComponents.kt, ui/screens/PlayerScreen.kt,
app/build.gradle.kts and latest.json. Added files are this report, the two Java production
helpers and the standalone verification source. Complete ZIP integrity was checked.

## Preserved and tradeoffs
Dependencies, provider URLs, network timeouts, decoder configuration and device SDK
support are unchanged. No UI redesign; all screen layout blocks remain unchanged.
Sports screen/repository and Sports-specific ViewModel logic are unchanged. MultiView
presentation is byte-identical, while its players inherit the new buffer policy.
Continue Watching storage and ViewModel logic, reporting, profiles and feature controls
are unchanged. Lifecycle cleanup changes internal resource retention, not visible controls.

The shorter retained VOD back buffer means longer rewinds may need to fetch data again.
A size-aware forward buffer can retain fewer seconds on high-bitrate streams, trading
network-jitter headroom for less memory pressure. Leaving a playback mode now unloads
that shared player; re-entry prepares it again using existing URL/resume logic. Guide
preview-to-live-fullscreen does not unload or restart the active player.

These are deeper resource and browsing optimizations, but no guaranteed major speed
increase or zero-bug claim is made. On-device validation must cover high-bitrate Live/VOD,
play/pause/seek/resume, rapid channel switches, Live-to-VOD transitions, Sports playback,
MultiView audio/fullscreen, Favorites/profile visibility and Home/Back exit.
