AVAssetDownloadTask not working in iOS 13 beta

I have an app that supports Offline HLS playback. The download was implemented based on Apple's guide at https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html


This feature is working fine, except on iOS 13 beta. When trying to download an HLS playlist using iOS 13, the download fails almost immediately. The error is:


Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundAVAssetDownloadTask <AFDCA3CC-FA49-488B-AB16-C74425345EE4>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(

"BackgroundAVAssetDownloadTask <AFDCA3CC-FA49-488B-AB16-C74425345EE4>.<1>"

), NSLocalizedFailureReason=An unknown error occurred (-16654)}


Does anyone know what could be the cause for this error? Thanks!

I have the same problem while downloading HLS via fairplay!

I also get the same error in iOS 13 beta 7 (17A5565b) in XCode 11 beta 5:


Task <7583C113-B837-4044-BD93-91E36F3435F1>.<1> finished with error [-11800] Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundAVAssetDownloadTask <7583C113-B837-4044-BD93-91E36F3435F1>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(

"BackgroundAVAssetDownloadTask <7583C113-B837-4044-BD93-91E36F3435F1>.<1>"

), NSLocalizedFailureReason=An unknown error occurred (-16654)}


I did not get this error with earlier iOS 13 beta 7 versions, but I'm unsure in what version this error was introduced.


UPDATE:

I have filed a Apple Bug report: FB7080599 (AVAssetDownloadTask not working in iOS 13 beta 7).


UPDATE:

This is still not solved in iOS 13 beta 8 or 13.1 beta. Does anyone have a solution or at least a clue on what might trigger this? I have tested the apple sample project "HLSCatalog" and download works fine with that solution with the predefined url's, but it fails with the above error when trying with my url's (but it succeeds on iOS 12). I have reported this to apple.

I also get the same error in iOS 13 beta 7 (17A5565b) in XCode 11 beta 6

I meet the same error in iOS 13 Beta 8 and reported to Apple. This is a serious problem. Don't know whether this will be fixed in next version.

Partial solution:

We have found out that the problem is most likely caused by a missing CODECS attribute in our m3u8 file (as described by the spec below). After adding this attribute, the problem seems gone.


https://tools.ietf.org/html/rfc8216:

”Each member in a Group of Renditions MAY have a different sample

format. However, any EXT-X-STREAM-INF (Section 4.3.4.2) tag or EXT-

X-I-FRAME-STREAM-INF (Section 4.3.4.3) tag which references that

Group MUST have a CODECS attribute that lists every sample format

present in any Rendition in the Group, or client playback failures

can occur.”


We are very curios what more has changed in iOS 13, except from the CODECS requirement. We have asked Apple for more info since there is no info in the iOS beta change logs.

Our root cause is just the same as yours.

We have to add CODECS attributes into the file.


Thank you for the solution.

I also been experincing the same issue through iOS 13 betas 1-8.

We've tried adding CODECS to our HLS, but still couldn't get it to work.

Do you have any idea on what's wrong to our HLS ? .


Our HLS m3u8 is as follow:


Airplay

-------------------------------

#EXTM3U

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1600000,RESOLUTION=1280x720,CODECS="avc1.640029,mp4a.40.2"

https://....m3u8

-------------------------------


https://....m3u8

-------------------------------

#EXTM3U

#EXT-X-VERSION:3

#EXT-X-MEDIA-SEQUENCE:0

#EXT-X-ALLOW-CACHE:YES

#EXT-X-TARGETDURATION:11

#EXT-X-KEY:METHOD=AES-128,URI="https://....?Expires=1567866367&Signature=....&Key-Pair-Id=...."

#EXTINF:10.276933,

https://.....ts

#EXTINF:10.677333,

....

Just tried ios 13.0 GM and still not working, I tried both AVAggregateAssetDownloadTask and AVAssetDownloadURLSession but none of them working. Not any delegate was called to tell me error of finish, and I found downloaded cache was only 25Kb what was not the right size.

Same for me, cant find any reason why.

The issue seems not fixed on iOS 13, 13.1, 13.1.1 and 13.1.2.

I have the same issue and have no solution. Tried m3u8 CODEC attribute, no luck.

My case is audio only HLS streaming.

If anyone have solution or even workaround, please kindly share.

I have the same problem too (

The file I implemented has the required properties written but still doesn't work.


clip_145.m3u8

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",LANGUAGE="en", DEFAULT=NO, AUTOSELECT=YES, URI="en.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Korean",LANGUAGE="ko", DEFAULT=NO, AUTOSELECT=YES, URI="ko.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Romanization",LANGUAGE="rz", DEFAULT=YES, AUTOSELECT=YES, URI="rz.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=295240,AVERAGE-BANDWIDTH=251002,CODECS="avc1.4d400c,mp4a.40.2",RESOLUTION=256x144,FRAME-RATE=29.970, SUBTITLES="subs"
clip_145_sub.m3u8


clip_145_sub.m3u8

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:2.002,
clip_145_00001.ts
...
...
#EXTINF:2.002,
clip_145_00107.ts
#EXT-X-ENDLIST


Nothing happens when I try to download to clip_145.m3u8. Is there another reason why it doesn't work?

Hi, everyone, I checked iOS13.4 beta3, it looks like working again.

I am also having the same issue. Do anyone have the solution.
AVAssetDownloadTask not working in iOS 13 beta
 
 
Q