Media Optimization in Apps

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Native SDKs often lack a full image pipeline: SwiftUI’s AsyncImage has no dedicated image cache, no prefetching and no downsampling, and a plain ImageView or Image decodes whatever it is given. This sub-section documents the libraries that fill the gap on each platform, how to show a BlurHash while an image loads, how to play adaptive video, and how to compress and upload media from the device. It is current as of 2026-10-07. This is the native and cross-platform app home of the topic: the server side that produces the variants is in Media Optimization for the backend, and the browser side is in Media Optimization for the web. The pages share one running example with the backend and web sections: the book cover b81f (2400 by 3600 pixels, AVIF, WebP and JPEG variants 320, 640 and 1280 pixels wide, and a BlurHash of 28 characters) and the video 42 with its 360p to 1080p ladder. Each page picks a variant for a 160 by 240 point tile from that JSON, and the Swift and Node programs behind the numbers on the pages were run, while the Kotlin, Dart and TypeScript code follows the official API documentation.

Deliberately out of scope. This section is about getting media that already exists in the right variants onto the screen, playing it, and sending new media back. The following topics appear in most native app books but live elsewhere on this site, or are intentionally not covered:

flowchart LR API["API: variants, blurhash, manifest"] --> IMG["Image library: cache, downsample, placeholder"] API --> VID["Video player: HLS or DASH"] CAM["Camera or gallery"] --> CMP["Compress on the device"] CMP --> UP["Background upload with a pre-signed URL"] UP --> API

What’s covered

Page What it covers

Android: Coil, Glide and BlurHash

Coil 3 caches and network artifacts, variant selection, sample-size and memory arithmetic, a cover grid, Glide modules and DiskCacheStrategy, Fresco, and a BlurHash placeholder.

Android Video with Media3

ExoPlayer for HLS and DASH, track selection limits for metered networks, a lifecycle-aware player, SimpleCache sizing, Transformer compression with a bitrate target and cover frames.

iOS: Kingfisher, Nuke and BlurHash

KFImage, DownsamplingImageProcessor, Nuke pipeline and LazyImage, cache configuration, a cover grid with variant selection, a Swift BlurHash decoder, SDWebImage, and the limits of AsyncImage.

iOS Video with AVFoundation

AVPlayer with HLS and rendition limits, AVAssetImageGenerator with rotation and tolerance, AVAssetExportSession presets and progress, and background uploads of parts.

React Native and expo-image

expo-image with blurhash and thumbhash, variant selection by pixel ratio, a cover grid, caching, compression before upload, react-native-blurhash, react-native-fast-image and react-native-video.

Kotlin Multiplatform and Flutter

Coil 3 multiplatform with shared variant selection, KMP BlurHash, expect and actual video players, cached_network_image with a cache manager and flutter_blurhash.

Device-Side Compression and Uploads

When to compress on the phone, ImageIO downsampling and encoding, HEIC and HEVC from iOS, multipart and resumable uploads with retries, and background workers.

Cheat Sheet (PDF)

A one-page summary of the libraries per platform, placeholder and cache settings.

Bibliography

Every source below is the official site, repository or documentation page of the library, service or standard it supports. Links were checked from an authoring environment with restricted outbound access. Entries marked (unverified) could not be opened from there (the site refused or blocked the request), so open them and confirm the content, version and status before you rely on them. Entries without the mark were opened successfully, or, for package pages, confirmed through the package registry.

React Native and Expo

Uploads

Other sources