Improving the Player on Android
Article Summary
Pinterest's Android team faced a unique challenge: playing multiple videos simultaneously in a two-column grid without killing performance. Here's how they optimized ExoPlayer to handle it.
The Pinterest Engineering team shares their deep dive into video player optimization for Android. They tackled startup latency, memory management, and bandwidth issues specific to their mixed-media feed experience.
Key Takeaways
- Warm up network connections with dummy HTTP HEAD requests before videos load
- Cut buffer durations to 500ms for short-form content (down from defaults)
- Disable audio rendering entirely for muted in-feed videos to save bandwidth
- Pool player instances by encoding type to avoid decoder switching overhead
- Purge corrupted cache on fatal IO errors to prevent persistent playback failures
By customizing ExoPlayer's DefaultLoadControl, DefaultTrackSelector, and building a smart player pool, Pinterest significantly reduced video startup latency while managing memory constraints.
About This Article
Pinterest's video player was slow to start because ExoPlayer was doing extra work. It kept calculating aspect ratios and triggering layout callbacks even though the video dimensions were already known.
The team set aspect ratios upfront using AspectRatioFrameLayout.setAspectRatio(). They also overrode PlayerView.onContentAspectRatioChanged() with an empty implementation to stop unnecessary recalculations.
Removing this redundant UI rendering work reduced video startup latency at Pinterest. The fix didn't require any changes to ExoPlayer itself.