v1.0.10 · Release snapshot

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/ImageCache only. 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-native Image. ImageCacheProps extends Omit<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 from onError.
  • 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:

// before
import { Image } from 'react-native';
<Image source={{ uri: track.coverUrl }} style={styles.cover} />

// after
import { ImageCache } from '@components/ImageCache';
<ImageCache source={{ uri: track.coverUrl }} style={styles.cover} />

The conversion between RN's resizeMode and expo-image's contentFit is automatic:

resizeMode (RN)contentFit (expo-image)
contain (default)contain
covercover
stretchfill
repeatcover

Forwarded expo-image props

On top of every standard ImageProps field, these expo-image extras are exposed via ImageCacheProps:

PropPurpose
transitionCross-fade duration in ms when the source changes.
cachePolicy'none' | 'disk' | 'memory' | 'memory-disk' (default 'disk').
priority'low' | 'normal' | 'high' — bias decode order for above-the-fold UI.
recyclingKeyStable id for FlatList cells so expo-image reuses decoded bitmaps.
decodeFormatAndroid only — 'argb' (default) or 'rgb' (16-bit, no alpha; lower memory).
enforceEarlyResizingiOS only — resize to container size before decode to cut memory on oversized sources.
useAppleWebpCodeciOS only — true (default) uses Apple's WebP codec; false uses libwebp for spec compliance.
onLoadFired after the asset is decoded + rendered.
onErrorForwarded — keeps existing fallback flows working.

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:

ImageCache.prefetch(uri);              // warm the cache off-screen
await ImageCache.loadAsync({ uri });   // promise-resolving prefetch
ImageCache.clearMemoryCache();         // drop RAM cache only
ImageCache.clearDiskCache();           // drop disk cache (rare)

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's Image is 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) — not ImageCache. The project has no react-native-svg dependency 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.getSize or read it from onLoad({ source: { width, height } }).

Migration checklist

For every remote-image call site:

  • Replace import { Image } from 'react-native' with import { ImageCache } from '@components/ImageCache'.
  • Rename JSX tag <Image .../> → <ImageCache .../>.
  • Keep source, style, resizeMode, onError unchanged.
  • (Optional) Add recyclingKey={item.id} inside FlatList renderItems.
  • (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