Error Downloading FairPlay content using AVAggregateDownloadTask

During intermittent download attempts or deleting the existing download and retrying itm getting the following error:

The operation couldn’t be completed. (CoreMediaErrorDomain error -12640.) Error Domain=CoreMediaErrorDomain Code=-12640 "(null)" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(\n    "BackgroundAVAssetDownloadTask <6476CB53-96B1-4AE6-88C3-EFDA3FC47F2F>.<2>"\n), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundAVAssetDownloadTask <6476CB53-96B1-4AE6-88C3-EFDA3FC47F2F>.<2>}

The method which throws the error:

func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)

While downloading the content we prefetch the persistent key using AVContentKeySession and save that locally. Once we got the key successfully we start the download using AVAggregateDownloadTask. Hence we are not getting any issue in obtaining key or with the key exipry. Issue comes only at download attempt of that content.

Background History of the issue:

This issue is a follow up of a previous major issue, which we understood is an encoding issue for fairplay content. The issue was occuring on downloading of the highest resolution of the content either if we select or let the aggregate task pick the hgihest by default on its own. We used to get the following error code in response of download attempt which always fails:

(CoreMediaErrorDomain error -12660 - HTTP 403: Forbidden)

Note: We have also managed session our streams to upto 1 minute if the attempt to play same link it will result in failure to access stream.

We fixed the issue by reducing the hls file size from backend encoding.

Now we are getting this follow up issue afterwards.

The problem is we are not able to get much information about the error code anywhere on the internet or documentation and not much help on forums as well. Generally people are getting this error at the time of key retrieval process. But we are getting via AVContentKeySession properly beforehand here and error coming only on download attempt of the content intermittently.

Error Downloading FairPlay content using AVAggregateDownloadTask
 
 
Q