AVAssetReaderOutput copyNextSampleBuffer fails on 10.15

Hi,


In the Vivaldi browser we use AVFoundation framework to decode video and audio files and network streams. In particular, we use AVAssetReader and AVAssetReaderOutput classes. The reader object receives AVURLAsset with a custom AVAssetResourceLoaderDelegate that loads data from the network.


Our code works without any issues on macOS 10.14 and earlier. However on macOS Catalina (all versions including 10.15.4) our users reported that sometimes they got errors while watching various videos. We found that the reason for the errors is a call to AVAssetReaderOutput copyNextSampleBuffer that returns null. After that a call to AVAssetReader status reports AVAssetReaderStatusFailed with error domain AVAssetReaderStatusFailed, code -11821 and error description "Cannot Decode". Typically the error happens when reading the audio track of the stream, but we also observed it with video data. The errors happens rather rarely and one can play the same stream many times before the error happens.


What is the meaning of that -11821 error? Does it indicate that the audio data got corrupted? Or does it indicate that AVAssetReaderOutput somehow ended in a bad state? And why does the error only happen on 10.15?

AVAssetReaderOutput copyNextSampleBuffer fails on 10.15
 
 
Q