Documentation comes from this release commit, without inheriting newer content. Commit: 63ea8c2b3d.
Images
All remote / cacheable images go through the shared <ImageCache> wrapper in src/components/ImageCache.tsx. The renderer underneath is expo-image, which gives us disk + memory caching, recycling keys, transitions, and prefetch — none of which react-native's Image provides out of the box.
Why a wrapper
- Decoupled API surface. Screens import
@components/ImageCacheonly. The day we swap to a different renderer (Fast Image, the New-Architecture image, an in-house native module) the renderer-specific types stay inside one file — no rename churn across features. - Drop-in for
react-nativeImage.ImageCachePropsextendsOmit<ImageProps, ...>so existing patterns (source={{ uri }},style,resizeMode,onError) keep working. Remote-→-local fallbacks (e.g.setPreferRemote(false)when a CDN URL 404s) continue to fire fromonError. - Memory cache. Call
ImageCache.clearMemoryCache()from debug menus if needed; there is no automatic OS memory-warning hook.
Usage
Replace react-native's Image for remote / large images:
The conversion between RN's resizeMode and expo-image's contentFit is automatic:
Forwarded expo-image props
On top of every standard ImageProps field, these expo-image extras are exposed via ImageCacheProps:
Any other expo-image prop that we haven't surfaced yet should be added to ForwardedExpoImageProps in ImageCache.tsx (not consumed via a direct expo-image import elsewhere).
Static helpers
ImageCache re-exports four expo-image statics so call sites never need to import expo-image directly:
prefetch is useful from a list-screen's onEndReached when you want to warm images ahead of scroll. Song-list covers rely on per-row <ImageCache> instead of catalog-level prefetch. clearDiskCache is almost never called from product code — it lives here for diagnostic / debug menus.
Memory-pressure integration
ImageCache.clearMemoryCache() can also be called manually from debug menus. On an OS memory warning, releaseMemoryPressure — wired once at the app root by useAppMemoryBootstrap — clears it every time; what the same handler does to the audio graph is described in features/piano.md.
The disk cache is intentionally left alone — decoded JPEGs survive a memory warning since the CDN round-trip is more expensive than the local re-decode.
Ephemeral FTUE screens
Onboarding and tutorial ship large bundled PNG heroes that are not needed after the user completes FTUE. Render them through <ImageCache cachePolicy="none" /> (not react-native Image). Metro already serves require() assets locally — skipping the expo-image cache lets decoded bitmaps release when the component unmounts, without a separate group-unmount cleanup hook.
Leave remote CDN covers on cachePolicy="memory-disk" (e.g. tutorial pick-song thumbnails) — those should survive FTUE and benefit from disk cache.
For tab-persisted screens that must stop work on navigation blur (e.g. song previews), use useFocusEffect instead — see usePreviewPlayback.
When NOT to use ImageCache
- Small static icons reused app-wide via
require('@assets/...'). RN'sImageis fine when the asset stays in the main app shell indefinitely. - UI icons. Render through the shared
<Icon>primitive (tinted PNGs from@assets/icons/manifest) — notImageCache. The project has noreact-native-svgdependency by design; see .cursor/skills/skia-svg-icons/SKILL.md. - Layout math on the raw bitmap. If you need decoded width/height before render (e.g. computing aspect ratio), prefer
Image.getSizeor read it fromonLoad({ source: { width, height } }).
Migration checklist
For every remote-image call site:
- Replace
import { Image } from 'react-native'withimport { ImageCache } from '@components/ImageCache'. - Rename JSX tag
<Image .../>→<ImageCache .../>. - Keep
source,style,resizeMode,onErrorunchanged. - (Optional) Add
recyclingKey={item.id}insideFlatListrenderItems. - (Optional) Add
transition={150}on hero images to mask network latency.
Existing call sites still using react-native Image (candidates to migrate):
None right now — the tracks detail screen that used Image was removed.
iOS build: disableLibdav1d
app.config.ts configures the expo-image config plugin with disableLibdav1d: true, which sets expo-image.disable-libdav1d in Podfile.properties.json on prebuild. That omits the CocoaPods libavif/libdav1d dependency (smaller IPA; drops bundled libavif.framework weight from the software AV1 decoder). PNG/JPEG/WebP and OS-backed AVIF paths are unchanged. Re-run npx expo prebuild --clean (or the next EAS iOS build) for the change to land in the native project.
See also
- src/components/ImageCache.tsx — the wrapper source.
- src/core/memory/ —
ResourceScope,useResourceScope. - expo-image documentation — every renderer prop we don't re-export still works at the underlying level.
- .cursor/skills/use-image-cache/SKILL.md — agent skill for adding / migrating call sites.