Add LazyColumn shortform demo with single-player preloading (addresses #1853)#2787
Add LazyColumn shortform demo with single-player preloading (addresses #1853)#2787Amud wants to merge 1 commit intoandroidx:releasefrom
Conversation
…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
|
hi @oceanjules , Please let me know if there are any feedbacks on this PR. |
|
Hi Amud, sorry for a delay, thank you for waiting! This is a great contribution and we appreciate the effort you've put into addressing the performance issues with the short-form demo. However, this pull request has grown quite large and mixes several distinct concepts. You PR adds production-like features which is a great example of how to build a short-form video feeds, but not a good example for a developer who wants to understand a single feature of the Media3 library. In a real-world app, this is exactly what would be expected from a developer to make a smooth experience for a user. However, our demo apps are not made to be standalone apps, but instead showcase particular features of the library, grouped by domain. There are users who might want a purely java+xml layouts example of using PreloadManager without having to untangle it from Compose UI. There are users who would want the Session Demo to be in Compose (#2418). Someone interested in using Media3 with Compose would be overwhelmed by the custom caching and preloading implementation. At the same time, we are not ready to productionise parts of this PR either because we do not have strong guidance about player management logic and how to keep a pool of players, what algorithm to use to evict old players and how to initialize more. We often use our own demo apps to ensure the feature will land well which is why we want them to be as lightweight as possible. When people report bugs, they should be able to quickly build the app and give us short reproduction steps. We can leave this PR for any developers who stumble upon it and want to study your code to get some inspiration for building a performant, short-form video app - although for better visibility I would advise you to make a Medium article :) |
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
PreloadManagerSolution
TargetPreloadStatusControlpreloads 3–5s for adjacent itemsmutableStateMapOftracks cache completionPerformance (observed)
Implementation highlights
LazyColumnPlayerManager: sliding window + preload managementLazyColumnTargetPreloadStatusControl: 3–5s buffer strategySinglePlayerSetupHelper: optimized load control and cacheTesting
Entry point
Adds a “LazyColumn” button in
MainActivityalongside the existing ViewPager demo.