Optimising image heavy applications
summary
Image decoding is CPU and memory heavy and UIImage often keeps decoded pixel buffers proportional to source resolution not view size, which explodes memory for large source images; decoding and caching cause fragmentation and can trigger compression or OOMs. Use Image I/O downsampling with CGImageSource with kCGImageSourceShouldCache=false and cgImageCreateThumbnailAtIndex to create thumbnails, run decoding asynchronously on a serial queue, and use collection view prefetching to avoid breaching the 16 ms frame budget.
AI-written summary · about
chapters (8)
- 0:00Start
- 5:58UIImage encapsulates this process
- 7:35However, decoding is expensive
- 12:16Downsampling - Step 1
- 15:25Dealing with CPU spikes due to downsampling
- 16:37Prefetching!
- 17:03Asynchronous downsampling serialQueue.async
- 17:50Additional Notes
related talks
14mReducing Image Memory Consumption in 10 Minutes
25mThe Life of an Image on iOS
35mFixing Image Performance for The Worst iPhone
27mGotta Go Fast (A Performance and Instruments Talk)
37mImage Formats, Performance and Cognitive Load
36mFast and Beautiful: Modern Image Delivery Techniques
45mThe image problem of the web and how to solve it…
01h 11mMoving Pictures
