HLS offline downloads can restart after a network switch when signed resource URLs expire

GitHub source

Inferred. This page is generated from GitHub Issue #26; GitHub remains the canonical authoring and discussion source.

Source#

Apple Developer Forums — “HLS VOD Download Resume after Wifi/LTE Change” (active September 2026):
https://developer.apple.com/forums/tags/media-player

The reported application downloads FairPlay-protected HLS VOD using AVAggregateAssetDownloadTask. During a Wi‑Fi → LTE transition, requests begin returning HTTP 403 because the application's token algorithm changes/invalidates playlist and segment URLs. Calling resume() does not continue from the previous downloaded position; starting a new download begins again.

Apple references:

Problem#

The tempting diagnosis is “AVAssetDownloadTask cannot resume after Wi‑Fi/LTE changes.” The stronger discriminator in the report is different:

network path changes
→ existing signed HLS resource URL returns 403
→ asset-download task completes with error
→ calling resume() cannot resurrect the failed request graph
→ creating a new asset/download with different signed URLs starts a new download

The media content may be byte-identical behind the new URLs, but AVFoundation is not documented to identify HLS resources by content equivalence across arbitrary URL changes.

The debugging question is therefore:

Did the network transition interrupt a still-valid background asset-download task, or did authentication turn the task's resource graph into a terminal HTTP failure?

Evidence level#

DOCUMENTED#

AVAssetDownloadTask is a URLSessionTask specialized for downloading HLS assets, and AVAssetDownloadURLSession manages those asset-download tasks. Apple’s offline-HLS guidance uses a background URLSessionConfiguration with a stable identifier and explicitly says existing asset-download tasks can be restored after app relaunch by recreating the session with the same identifier and querying its tasks.

This establishes task restoration/continuation as the supported model. It does not establish a public contract for rebuilding a failed HLS download from a newly signed master URL while preserving arbitrary partial resources from the old task.

Apple's generic URLSessionDownloadTask documentation separately describes resumeData, but AVAssetDownloadTask is not documented with an equivalent app-controlled resume-data API. Do not transfer URLSessionDownloadTask resume-data semantics onto HLS asset downloads without an AVFoundation contract.

AVAggregateAssetDownloadTask is now deprecated; current SDKs direct developers to makeAssetDownloadTask(downloadConfiguration:) / AVAssetDownloadConfiguration.

OBSERVED#

The forum report says:

  • protected HLS VOD is being downloaded;
  • the task is an aggregate asset download;
  • Wi‑Fi → LTE transition is followed by HTTP 403;
  • playlist/segment URLs use token algorithms and may change;
  • attempting to resume does not continue the failed download;
  • creating a new download for the same logical content begins again.

The 403 is a critical observation: it is an application/origin authorization response, not evidence that the radio/network transition alone invalidated AVFoundation's download state.

IMPLEMENTATION EVIDENCE#

None currently proves how AVFoundation keys every persisted partial HLS resource internally. Package contents and request traces may expose that behavior, but they are not public identity contracts.

INFERENCE#

A strong leading model is that the original task can continue only while its resolved HLS resource graph remains usable. Once token expiry/path-specific signing causes requests in that graph to return 403 and the task terminates, constructing a new AVURLAsset whose master/child URLs differ is a new task/resource identity problem; byte-equivalent media is insufficient to guarantee reuse.

UNKNOWN#

  • Whether the token expires because of elapsed time, IP/network binding, CDN policy, or application signing logic.
  • Whether the original background task would continue automatically across Wi‑Fi/LTE if all previously resolved URLs remained authorized.
  • Whether the server can issue stable resource URLs with authorization conveyed independently of resource identity.
  • Exact partial-resource reuse behavior for a newly created asset whose signed URLs differ.
  • Whether a current AVAssetDownloadConfiguration task changes behavior relative to the deprecated aggregate API for this scenario.

Investigation / Explanation#

Separate network continuity, authorization continuity, task identity, and resource identity.

Use this state model:

AVURLAsset(master URL)
→ asset-download task identity
→ master/media playlist resolution
→ signed child resource URLs
→ background request execution
→ partial local package
→ network path change
→ next request authorization
→ task continues OR HTTP failure terminates task

Do not treat these as equivalent:

Wi‑Fi → LTE

and:

Wi‑Fi → LTE → signed URL becomes unauthorized → HTTP 403

The decisive control is to make the network transition while keeping the exact same URLs valid.

Capture one monotonic timeline containing:

network path: Wi‑Fi / cellular
asset-download taskIdentifier
AVURLAsset URL
master URL
media-playlist URL
segment URL
HTTP status
redirects
request start/end
loaded time ranges / progress
URLSession task state
completion error
FairPlay key callbacks

For signed URLs also record non-secret metadata:

token issue time
token expiry time
whether signature is IP/path/session bound
logical resource ID
URL before/after refresh

Never log bearer tokens or CKCs into ordinary analytics.

The first A/B must remove authentication failure#

Run the same VOD with sufficiently long-lived URLs:

Wi‑Fi
→ download partially
→ switch to LTE
→ keep exact master/media/segment URLs valid

If the same task continues, the network switch is not the root cause; token/auth continuity is.

If it still fails without any 4xx response, investigate background-session/network migration separately.

Do not use URLSession resumeData as the model#

Generic URLSessionDownloadTask can expose resume data under documented conditions. HLS asset downloading is a different abstraction: AVFoundation resolves a manifest graph and persists an HLS package. There is no documented AVAssetDownloadTask API that accepts generic download-task resume data to reconstruct a failed HLS graph.

The supported persistence model to test first is:

same AVAssetDownloadURLSession identifier
→ restore/query existing asset-download task
→ allow that task to continue

not:

failed HLS task
→ obtain generic resumeData
→ create a new HLS asset task from it

Keep FairPlay separate#

For offline protected HLS, two independent lifetimes exist:

media authorization:
signed manifest/segment URL → HTTP success

content authorization:
KID → persistable content-key request → CKC → persisted key

An HTTP 403 for a playlist/segment occurs before media bytes are available and is not evidence of a FairPlay CKC failure.

Only enter FairPlay debugging if content-key callbacks fail before the media request failure.

Verification matrix#

Use the same VOD and device:

A. Wi‑Fi only, long-lived stable URLs
B. Wi‑Fi → LTE, same URLs remain valid
C. Wi‑Fi → LTE, deliberately expire token before switch
D. Wi‑Fi → LTE, token remains valid by time but is IP/network-bound
E. Wi‑Fi → LTE, failed task then resume() same task
F. Wi‑Fi → LTE, failed task then create new task with refreshed URL
G. terminate/relaunch app while task is healthy; restore same background session
H. current AVAssetDownloadConfiguration API with equivalent content

For every run capture:

same taskIdentifier?
same master URL?
same child resource URLs?
first HTTP status after transition
completion error timestamp
progress before/after transition
whether existing local package grows
whether a new destination/package is created
AVAssetCache state when applicable

Interpretation:

B succeeds, C fails
→ authentication expiry is isolated from network migration

B succeeds, D fails
→ network/IP-bound signing is the causal discriminator

G resumes
→ background task restoration works while task/resource identity remains intact

E cannot progress after terminal 403, F restarts
→ task termination + changed resource identity is the relevant boundary

B fails without HTTP/auth errors
→ investigate AVAssetDownloadURLSession path migration/runtime behavior

Solution / Guideline#

  1. Design signed HLS URLs for the maximum offline-download transaction lifetime. A VOD download may outlive a normal streaming token window.
  2. Avoid binding download authorization to transient client properties such as source IP/network interface if the product expects Wi‑Fi ↔ cellular migration.
  3. Prefer stable resource identity during one asset-download task. If authorization must refresh, do not assume AVFoundation will deduplicate a new set of arbitrary signed URLs against partial resources from a terminated task.
  4. Use a background AVAssetDownloadURLSession with a stable configuration identifier and restore existing tasks rather than recreating healthy downloads after app lifecycle changes.
  5. On current SDKs, migrate from deprecated AVAggregateAssetDownloadTask to AVAssetDownloadConfiguration / makeAssetDownloadTask(downloadConfiguration:); verify required media selections after migration.
  6. Treat HTTP 401/403 as authorization failures first. Record which exact HLS resource first became unauthorized before debugging AVFoundation resume behavior.
  7. Keep FairPlay persisted-key lifetime independent from media-URL token lifetime. A valid persisted key cannot make a 403 media segment downloadable.
  8. If the service cannot maintain authorization continuity for the original HLS resource graph, treat restart/re-download as a product/server-auth design problem unless Apple documents a supported URL-refresh mechanism for asset downloads.

Reusable engineering rule#

Resumability requires identity continuity, not merely content equivalence.

For offline HLS, preserve the distinction:

same logical movie
        ≠
same AVAssetDownloadTask
        ≠
same HLS resource graph
        ≠
same authorized resource URLs

When a download fails during a network switch, find the first broken continuity boundary:

network path
→ request authorization
→ resource URL identity
→ asset-download task state
→ partial package reuse

If the first failure is HTTP 403, solve or isolate authorization continuity before attributing the restart to AVFoundation's network-resume machinery.

References#