I have encountered the same error. A stream that had no observable damage was stopping at a certain point. I've found a fix, which is to manually set some value for the currentItem's preffered buffer size:
player.currentItem.preferredForwardBufferDuration = 1
The system wont honor your desire for the buffer size for some reason, but it fixes the bug.