iosavplayerhttp-live-streamingavplayeritem

AVPlayer throwing : "Internal error: restarting too far ahead"


I am observing KVO AVPlayerItemNewErrorLogEntryNotification of the AVPlayer and I find the following error:

I am unable to understand what the below line really means.

"Internal error: restarting too far ahead"

Can anyone help me to find the root cause of this issue.


Solution

  • According to an Apple employee this error message means that:

    The player is complaining that it was trying to restart a live stream, but only had 1.4 seconds of material available. How many segments are in your live playlist? These days we recommend that you always have at least six segments in the playlist. I believe the only effect is to delay palyback until it has enough data.

    Source: https://forums.developer.apple.com/thread/40791


    The cause of the error most probably originates from the m3u8 itself.

    When streaming a live program (e.g. any TV channel) there is a delay between the availability of event data and the encoder creating media segments (.ts) that are then appended to the playlist.

    I could imagine that these types of errors are generated if the playerItem playhead's position is at the very edge of the buffer and new media segments are not made available fast enough on the server.


    Should these errors be prevented or handled on the client's side:

    Since these errors are reported as internal and AVPlayer apparently recovers from it, it is safe to assume that they are being handled internally. They could therefore be understood as simple error reporting and one could choose to ignore them.

    If one wanted to prevent them, the only way to do this might be to manually set the live buffer's edge back in time a few seconds.