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:
-
Camera capture, pickers and photo library permissions — see Apple: Camera, Media and Photos, Android: Camera, Location, Sensors and Media and React Native: Device Capabilities. Only what the picker returns is used here.
-
Photo filters, Core Image and editing — not covered; this section resizes and re-encodes, and does not edit content.
-
Audio playback and recording — not covered beyond the audio track inside a video; the platform media pages above start there.
-
Image layout and views (
ImageView, SwiftUIImage, content modes) — see Android: Views and Layouts, SwiftUI controls, text and images and React Native: Images and Icons. -
Concurrency (threads,
asyncandawait, coroutines) — see Apple: Concurrency in Apps and Android: ViewModel, Lifecycle and Coroutines; the pages use them without teaching them. -
Background work and services — see Apple: Background Execution and Android: Background Work and Services; only the upload side is repeated here.
-
Networking basics and JSON — see Apple: Networking, Android: Retrofit, OkHttp and Ktor and React Native: Networking and Data Fetching.
-
Persisting media and offline sync (Core Data, Room, files, offline queues) — see Apple: Core Data, CloudKit and iCloud, Android: Local Storage and Files and React Native: Storage and Offline; this section only covers HTTP caches of downloaded media.
-
Permissions and privacy prompts — see Android: Permissions, Privacy and Security and Apple: Security and Privacy.
-
Cross-platform framework basics — see Kotlin Multiplatform and React Native; the hybrid frameworks are documented in Flutter and Dart and Ionic and Capacitor.
-
Producing the variants (encoding, formats, upload pipelines, thumbnails) — see Media Optimization for the backend and upload pipelines.
-
Browsers — see Media Optimization for the web.
-
DRM, live streaming and video calls — FairPlay, Widevine, WebRTC and live ingest are not covered; this section plays on-demand video only.
-
Managed image and video services — see AWS, Google Cloud and Azure.
What’s covered
| Page | What it covers |
|---|---|
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. |
|
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. |
|
KFImage, DownsamplingImageProcessor, Nuke pipeline and LazyImage, cache configuration, a cover grid with variant selection, a Swift BlurHash decoder, SDWebImage, and the limits of AsyncImage. |
|
AVPlayer with HLS and rendition limits, AVAssetImageGenerator with rotation and tolerance, AVAssetExportSession presets and progress, and background uploads of parts. |
|
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. |
|
Coil 3 multiplatform with shared variant selection, KMP BlurHash, expect and actual video players, cached_network_image with a cache manager and flutter_blurhash. |
|
When to compress on the phone, ImageIO downsampling and encoding, HEIC and HEVC from iOS, multipart and resumable uploads with retries, and background workers. |
|
A one-page summary of the libraries per platform, placeholder and cache settings. |
Related material on this site
-
Android: Image Loading with Coil and Glide, Apple: Camera, Media and Photos and React Native: Images and Icons are the platform references this section builds on.
-
BlurHash: The Algorithm explains the placeholder string.
-
Media Optimization for the web is the browser counterpart.
-
Media Optimization for the backend is the server side: formats, variants, transcoding and upload pipelines.
-
Video Playback and Streaming and Next.js Image show the same variant choice and ladder in the browser.
-
Video Encoding Fundamentals, Responsive Images and Thumbnails and Security and Operations define the variants, the ladder and the checks that the apps rely on.
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.
Android
-
Coil getting started (unverified)
-
Coil, image loaders (unverified)
-
Coil, network (unverified)
-
Fresco (unverified)
-
Glide caching (unverified)
-
Glide Compose integration (unverified)
-
vanniktech/blurhash (unverified)
-
woltapp/blurhash, Kotlin implementation (unverified)
iOS and Apple platforms
-
Kingfisher (unverified)
-
Kingfisher, API documentation (unverified)
-
Kingfisher, cheat sheet (unverified)
-
Nuke (unverified)
-
SDWebImage (unverified)
-
woltapp/blurhash, Swift implementation (unverified)
React Native and Expo
-
Expo, expo-image documentation (unverified)
-
Expo, expo-video documentation (unverified)
-
react-native-blurhash (unverified)
-
react-native-fast-image (unverified)
-
react-native-video (unverified)
Uploads
-
tus, resumable upload protocol (unverified)
Other sources
-
Nuke documentation (unverified)