This is a very weird bug.
I have a tableView with each cell using an AVPlayer
to stream a video from a remote server (think a Vine-like timeline). So when I scroll, the cells that get reused reconfigure their player with the new video.
The problem is: if I scroll back and forth very fast, getting the same video in and out of the screen, the request sent by the AVPlayer eventually changes, to include the HTTP Headers If-None-Match
and If-Modified-Since
, which are not there the rest of the time. It systematically makes the server return a 304 Not Modified
response.
That doesn't seem to please the AVPlayer's playerItem, which changes its status to AVPlayerItemStatusFailed
(interestingly, the AVPlayer's status is still AVPlayerStatusReadyToPlay
). The error is AVErrorUnknown
(-11800) with an OSStatus -12983 (which isn't documented anywhere and is in no header in the entire iOS SDK).
That's when it gets weird: whatever I do next, the AVPlayer and its playerItem are irrevocably burnt. Even if I reconfigure them with another asset, they'll just return this status and show a black frame. Weirder still: even if I initialize another AVPlayer, AVPlayerItem and AVAsset, it just won't play anymore, I have to kill and restart the app.
At this point, I'm pretty clueless. Any idea what's happening here? Preventing the player from including these headers in its connection would fix it, but it's not exposing its request serializer.