AVPlayerItem loadedRangeTime and Player Item duration no not match when fully loaded.

Originator:rshanbag
Number:rdar://39282364 Date Originated:04/09/2018
Status:Open Resolved:
Product:iOS Product Version:iOS 11.3/Xcode 9.3(9E145)
Classification:Bug Reproducible:
 
Area:
AVFoundation

Summary:
There is a mismatch between player item duration and the full loaded time range 
of AVPlayerItem while streaming HLS and the network is poor. KVO-ing on duration clearly shows duration switching mid stream but the loaded time Range never satisfies that requirement. Due to this, `isPlaybackBufferFull` and `isPlaybackLikelyToKeepUp` and never flipped to true resulting in infinite stall.  

Steps to Reproduce:
1. Turn on NLC on iOS/mac OS.
2. Setup KVO for AVPlayerItem duration, loadedTimeRange, isPlaybackBufferFull and isPlaybackLikelyToKeepUp
3. Play the HLS Stream using AVPlayer.
4. Observe how duration switches midway. 

Expected Results:
loadedTimeRanges should add up to the net duration of the item and there shouldn't be an infinite stall. 

Actual Results:
They don't match which results in player item trying to load forever.

Version/Build:
iOS 11.3 / Xcode 9.3(9E145)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!