Introducing Twitter Image Pipeline iOS Framework For Open Source
Article Summary
Twitter open sourced their iOS image pipeline after hitting a breaking point: 2GB caches, corrupted images, and no way to clear data when users logged out. Here's how they rebuilt it from scratch.
In 2017, Twitter's engineering team released TIP (Twitter Image Pipeline), their battle-tested iOS framework for image loading and caching. After two years of internal iteration solving critical performance and reliability issues, they made it available to the broader iOS community.
Key Takeaways
- Reduced cache size from 2GB+ to 128MB using LRU purging and configurable limits
- Three-tier caching system: rendered in-memory, raw in-memory, and persistent on-disk
- Progressive JPEG support delivers content faster on slow connections worldwide
- Automatic request coalescing and download resuming minimize wasted network calls
- Pluggable codec architecture supports JPEG, PNG, GIF, WebP, and custom formats
Twitter's TIP framework solved years of tech debt including cache corruption, unbounded storage growth, and wasteful networking through isolated pipelines and intelligent variant loading.
About This Article
Twitter's image pipeline had race conditions where the same image would load twice from the network. Both writes would corrupt the cached file, and the problem got worse with slow connections and larger images.
Twitter built the TIP framework to fix the race condition. It uses thread-safe cache design and data consistency checks so multiple users can access cached images at the same time without corrupting files.
TIP's caching fixed the core issue that plagued the old system. Twitter can now deliver images reliably to millions of concurrent users without the corruption problems that used to hurt the experience.