[expo-media-library] Query.exe() should support returning populated asset data (bulk fetch performance)
E
EX John
Query.exe() returns Asset instances that are thin wrappers around IDs. Retrieving actual asset metadata (uri, mediaType, duration, timestamps,
dimensions) requires calling getInfo() individually on each asset. For large collections (10k–100k assets, common in photo picker UIs), this
creates a 1 + N native round-trip problem that makes the new API orders of magnitude slower than the legacy getAssetsAsync.
Current behavior
iOS — Query.exe() fetches PHFetchResult<PHAsset>, then discards all data and returns only Asset(localIdentifier:):
// Query.swift:97-106
func exe() async throws -> [Asset] {
let fetchOptions = constructFetchOptions()
let phFetchResult = try await fetch(fetchOptions)
return sliceFetchedAssets(from: phFetchResult)
.map { Asset(localIdentifier: $0.localIdentifier) } // data discarded here
}
Android — Query.exe() queries only _ID and MEDIA_TYPE, then wraps into Asset(uri):
// Query.kt:96-109
val projection = arrayOf(
MediaStore.Files.FileColumns._ID,
)
Each subsequent getInfo() call re-queries the underlying store (PHAsset.fetchAssets(withLocalIdentifiers:) on iOS, a new MediaStore cursor on
Android).
Environment
- expo-media-library: 56.0.5
- Expo SDK: 56