Performance for Everyone
Article Summary
Lin Wang from Pinterest's Android Performance team just solved a problem that costs most teams two engineer-weeks per feature: measuring user-perceived latency. Their solution? Make it completely automatic.
Pinterest's performance team built an ingenious system that automatically measures 'Visually Complete' (when users actually see content) across all app surfaces. Previously, engineers had to manually implement custom measurement logic for each feature, creating a major barrier to performance work.
Key Takeaways
- Reduced performance measurement from 2 engineer-weeks to zero per surface
- System walks the view tree to detect when all images, text, and videos render
- Now automatically tracks 60+ surfaces across Android, iOS, and web
- Product engineers get latency metrics free when building on base UI classes
By baking performance measurement into base UI classes, Pinterest democratized performance monitoring and now tracks user-perceived latency across 60+ surfaces with zero manual effort per feature.
About This Article
What counts as 'Visually Complete' changes depending on where you are in Pinterest. On Video Pin Closeup, it means the full-screen video has loaded. On Home Feed, all images need to be rendered. On Search, you're waiting for autocomplete text and avatars. Because these definitions are so different, engineers had to write custom measurement logic for each surface.
Lin Wang's team created common media view interfaces called PerfImageView, PerfTextView, and PerfVideoView. Each one has methods to track rendering status. They then built traversal logic into BaseSurface that walks through the view tree and detects when all visible media elements have been drawn or have started playing.
The system now tracks user-perceived latency across 60+ surfaces at the same time. Product teams can compare performance fairly across different features. They can also measure short-lived features like seasonal landing pages without needing engineers to set things up beforehand.