I am trying to do the stack overflow claimed impossible task of achieving ~60fps scroll performance in a collection view which contains some videos here and there (auto-playing). I have spent months on this and attempted every solution presented online and have gotten very very close. Creating the asset on a background thread and adding to the view is fine and having it auto play is all great, I can do that without any hiccups in performance.
The ONLY issue I have is that over time I build up a lot of instances of the player (even tho I am reusing the player and playerLayer in my cells...
Now this is fine for a while until the user has seen many videos and then eventually the videos just stop playing, obviously as there are so many instances active. To stop this build-up I need to remove the playerLayer from the superview every time, or replace the media item (which we all know runs on main thread and makes this task impossible).
SO, my question is, is there ANY OTHER WAY to kill off these old threads? If so, I will have finally found a solution to smooth scrolling with AVPlayer and I can return the favor to the community and post all my code!