Search code examples
iosavfoundationavplayeravplayeritem

Why AVAudioSessionMediaServicesWereResetNotification can happen very often (iOS 10)?


I'm developing video caching system for AVPlayer using AVAssetResourceLoaderDelegate. But I found out that sometimes media services reset (AVAudioSessionMediaServicesWereResetNotification notification) happens about every 10 seconds, what leads to reinitialization of all AVPlayerItem and AVPlayer objects and stuttering playback.

Have someone faced with the same problem? Probably some threading issues, or AVAssetResourceLoader limitations?

Thanks


Solution

  • Found solution on this problem.

    I was loading values and thumbnail for multiple AVPlayerItems asynchronously in background. The key mistake was that values were requested in thread where AVPlayerItem and its AVAsset were allocated, but thumbnail (using AVAssetImageGenerator) was requested in another thread. When I moved thumbnail request to the same thread as values request media services reset disappeared.