SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
158 stars 33 forks source link

iOS 12 issues #53

Closed defagos closed 5 years ago

defagos commented 6 years ago

On iOS 12, there are playback start issues, leading to failing unit tests and glitches when starting a video (try e.g. playing the Apple advanced stream a few times).

The standard iOS player does not seem affected, which means something has changed (as always with each iOS major release...), but that a fix is possible on our side.

defagos commented 5 years ago

When built with the iOS 12 SDK and run on iOS 12, we get the cancellation errors very often, e.g.

Task <0AE3A4B5-7D68-4CE6-AA76-2675307F752E>.<4> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear1/main.ts, NSErrorFailingURLKey=http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear1/main.ts, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <0AE3A4B5-7D68-4CE6-AA76-2675307F752E>.<4>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0AE3A4B5-7D68-4CE6-AA76-2675307F752E>.<4>, NSLocalizedDescription=cancelled} [-999]
2018-09-19 15:29:41.202625+0200 SRGMediaPlayer-demo[21636:4716620] Task <0AE3A4B5-7D68-4CE6-AA76-2675307F752E>.<4> finished with error - code: -999

Those are internal AVPlayer-induced errors, with the result that sometimes tracks get lost. The same errors can be seen when playing a media with the standard AVPlayerController, which proves this is not an error within our implementation which generates them.

It seems that such errors are related to AVPlayer losing its tracks. Currently, when the playback view detects that only an audio track is available, it removes the video view, which leads to the reported stuttering and glitches.

I doubt these lines are required, they were probably mostly a safety net. Removing them fixes the issue without affecting the unit test suite, which is good. We need to investigate whether everything still works as expected, though, but this fix seems promising.