Skip to content

Conversation

Amud
Copy link

@Amud Amud commented Sep 18, 2025

MicrosoftTeams-video.mp4

Adds a LazyColumn-based shortform demo that optimizes a single-ExoPlayer setup with preloading, addressing performance concerns raised in #1853.

Related issue

Fixes #1853.

Background

  • Initial frame delays with single player + PreloadManager
  • Lag on first video and during transitions
  • Performance gap vs a multi-player pool approach

Solution

  • Window-based media management
    • Sliding window (~10 items) with dynamic load/unload based on scroll
    • Reduces memory pressure while maintaining smooth playback
  • Optimized preloading
    • TargetPreloadStatusControl preloads 3–5s for adjacent items
    • Preloads items at distance ±1 and ±2
  • Reactive cache tracking
    • mutableStateMapOf tracks cache completion
    • Thumbnails load only after content is cached
  • Single player benefits
    • Lower memory use than a 3‑player pool
    • Simpler state management with smooth transitions

Performance (observed)

  • Reduced initial frame delay via targeted preloading
  • Windowing avoids memory exhaustion
  • Cache-aware thumbnails improve perceived responsiveness
  • Consistent transition smoothness across indices

Implementation highlights

  • LazyColumnPlayerManager: sliding window + preload management
  • LazyColumnTargetPreloadStatusControl: 3–5s buffer strategy
  • SinglePlayerSetupHelper: optimized load control and cache
  • Compose UI reacts to cache status changes

Testing

  • Transitions across all items
  • Smooth playback without noticeable frame drops
  • Stable memory during extended scrolling
  • No rendering delays after initial cache warm-up

Entry point

Adds a “LazyColumn” button in MainActivity alongside the existing ViewPager demo.

…ndroidx#1853)

Implements optimized single-player architecture for shortform content that
addresses the performance issues described in androidx#1853.

Key optimizations:
- Sliding window management (10 items) with dynamic loading
- Aggressive preloading for adjacent items (3-5 second buffers)
- Reactive cache status tracking prevents premature thumbnail loading
- Optimized load control settings for quick start (500ms buffer)

This provides a performant alternative to multi-player pools while
maintaining lower memory overhead and simpler architecture.

Fixes androidx#1853
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blank/Slow Frame Render for videos (Shortform Demo)
2 participants