[iOS 16] AVAggregateAssetDownloadTask reports CoreMediaErrorDomain Code=-12640

I'm trying to download HLS assets using AVAggregateAssetDownloadTask. It's pretty stable on iOS < 16.0. But after updating to iOS 16 I'm getting randomly following error:

Task <DB57343C-5D3A-4500-A886-A30FD16AD2C3>.<3> finished with error [-12640] Error Domain=CoreMediaErrorDomain Code=-12640 "(null)" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(

    "BackgroundAVAssetDownloadTask <DB57343C-5D3A-4500-A886-A30FD16AD2C3>.<3>"

), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundAVAssetDownloadTask <DB57343C-5D3A-4500-A886-A30FD16AD2C3>.<3>}

Few retry attempts usually solve the issue. I have compared requests made by the app using proxy server and .m3u8 playlist does not differ between successful and failed download attempts.

This is the network traffic when download fails. It stops on ...Audio_Selector.m3u8 playlist.

And this is the network traffic when download successfully continues:

Thanks!

Post not yet marked as solved Up vote post of AFoley Down vote post of AFoley
2.1k views
  • Have you succeeded in fixing this? We’re having the exact same issue when trying to download DRM protected content on iOS 16.

    Maybe someone from Apple can also respond here?

Add a Comment

Replies

Facing the similar issue. Did anyone get any solution?

Facing the similar issue. and Few retry attempts is not a permanent solution for above iOS 16.

I found out that we only have this issue with URLs that change over time due to the query parameter containing a token for expiring the URL and signing the URL. So if AVFoundation downloads the manifests multiple times with some time in between the token will change slightly due to the different timestamp.

My company filed a DTS and they let us know that STABLE-VARIANT-ID (see also STABLE-RENDITION-ID) may fix this issue. When testing downloads with a Proxy that overrides manifests to include these stable identifiers as arguments we reduced the -12640 error a lot, but not completely.

We got new errors instead however. But these occur still less often. So with these attributes AVAssetDownloadTask works better for us, but still fails from time to time. -15602 -16657

https://developer.apple.com/forums/thread/674090 https://stackoverflow.com/questions/66600288/avaggregateassetdownloadtask-error-domain-coremediaerrordomain-code-16657