Source#
Apple Developer Forums — current question under the Video / HLS tags: “How does AVAssetDownloadConfiguration select video variants?”
Forum index: https://developer.apple.com/forums/tags/video
Authoritative Apple references:
AVAssetDownloadContentConfiguration.variantQualifiers: https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration/variantqualifiersAVAssetDownloadContentConfiguration: https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration- WWDC21 — Explore HLS variants in AVFoundation: https://developer.apple.com/videos/play/wwdc2021/10143/
Problem#
A developer downloads a multivariant HLS asset with AVAssetDownloadConfiguration. With no variantQualifiers, testing produces one completed video variant. When inspecting the resulting .movpkg, boot.xml can mention another video stream as incomplete, creating the impression that AVFoundation may be downloading several matching variants or switching between them during the download.
The developer also asks whether a broad qualifier such as:
NSPredicate(format: "peakBitRate > 0")causes every matching video variant to be downloaded.
Evidence level#
DOCUMENTED#
Apple's API contract is decisive: variantQualifiers are evaluated in preference order until a qualifier matches one or more playable AVAssetVariants. If more than one variant matches, automatic variant selection chooses among the matched variants. If no qualifier is provided, or no qualifier matches, automatic variant selection is used.
Therefore a predicate that matches all variants is not a request to download all variants. It defines a candidate set from which automatic variant selection chooses.
WWDC21 shows qualifiers as preferences/constraints for primary and auxiliary content configurations, and shows separate auxiliary content configurations when additional variant families are intentionally required.
OBSERVED#
The forum reporter sees one video stream marked complete in .movpkg; another can appear as incomplete in boot.xml, while a third advertised master-playlist variant may not appear there at all.
IMPLEMENTATION EVIDENCE#
boot.xml / .movpkg internals can reveal implementation state, but Apple does not document an incomplete stream entry as proof that AVFoundation intended to persist that rendition as a completed offline variant.
INFERENCE#
An incomplete entry may represent discovery, temporary selection state, bookkeeping, or partially materialized internal state. Its exact meaning is not established by the public contract.
UNKNOWN#
- The exact automatic-selection heuristic used when multiple variants satisfy a qualifier.
- Whether the heuristic changes with resolution, bitrate, device capability, storage conditions, or OS release.
- The exact semantic meaning of every incomplete
boot.xmlstream record.
Investigation / Explanation#
Model the API as:
master playlist variants
↓
current-device playability filtering
↓
variant qualifier #1
├─ no matches → qualifier #2
└─ one or more matches
↓
automatic variant selection
↓
selected offline presentation
↓
.movpkg materialization
This is different from:
predicate matches N variants
↓
download all N variants
If the product requires an exact variant, use a qualifier constructed from an explicit AVAssetVariant where appropriate. If the product requires additional variant families, model them as additional content configurations rather than relying on one broad predicate to mean “download everything.”
Do not infer the chosen variant from BANDWIDTH alone. Apple documents the fallback as automatic variant selection, not “highest bandwidth wins.” The reporter's highest-bandwidth result is an observation for those test manifests, not a stable selection contract.
Similarly, the older deprecated AVAssetDownloadTaskMinimumRequiredPresentationSizeKey documentation states that the legacy default selected the largest media presentation size, but that legacy behavior must not be generalized into a current variantQualifiers rule when the current API explicitly delegates multi-match resolution to automatic selection.
Verification matrix#
Create a master with three clearly distinguishable variants and record AVAsset.variants before download plus the completed local result afterward:
A. no variantQualifiers
B. qualifier matching exactly one variant
C. qualifier matching all variants: peakBitRate > 0
D. qualifier matching two of three variants
E. explicit AVAssetVariant qualifier
F. two ordered qualifiers where #1 has no match and #2 has one match
G. two ordered qualifiers where #1 matches multiple variants
Repeat with:
1. same resolution, different BANDWIDTH
2. different resolutions
3. different VIDEO-RANGE where device supports both
For each run capture:
OS/device
playableVariants
qualifier order and predicate
variants satisfying each predicate
network media-playlist/segment requests
resolved media selection delegate callbacks
completed local video stream(s)
AVAssetCache.isPlayableOffline
.movpkg inspection (implementation evidence only)
Expected contract-level interpretation:
one predicate matches many
→ candidate set, then automatic selection
first qualifier has matches
→ later qualifiers are not the next “variants to download”
explicit variant qualifier
→ that variant is the direct requested variant
Solution / Guideline#
- Treat
variantQualifiersas ordered variant-selection constraints/preferences, not a batch-download query language. - Never use
peakBitRate > 0expecting all matching video renditions to be persisted. - If exact offline quality is a product requirement, inspect
AVAsset.variantsand construct a qualifier that identifies the intended variant instead of depending on automatic selection. - If multiple distinct offline content configurations are required, use primary plus auxiliary content configurations deliberately and verify the resulting local asset.
- Treat
.movpkg/boot.xmlas diagnostic implementation evidence only; product correctness should be checked through public AVFoundation APIs and actual offline playback. - Do not encode “highest BANDWIDTH is the default” into application logic unless Apple documents that rule for the API/version being used.
Reusable engineering rule#
A selection predicate defines eligibility; it does not define multiplicity.
For AVFoundation HLS downloads, keep these concepts separate:
variant advertised
→ variant playable on this device
→ variant matches qualifier
→ variant chosen by selection policy
→ variant persisted
The fact that several variants pass the same predicate does not mean they all cross the final persistence boundary.
References#
- Apple Developer Forums — current Video/HLS question: https://developer.apple.com/forums/tags/video
- Apple —
AVAssetDownloadContentConfiguration.variantQualifiers: https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration/variantqualifiers - Apple —
AVAssetDownloadContentConfiguration: https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration - Apple WWDC21 — Explore HLS variants in AVFoundation: https://developer.apple.com/videos/play/wwdc2021/10143/
- Apple — deprecated minimum-presentation-size download option (useful only as historical API context): https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskminimumrequiredpresentationsizekey