CachingPlayerItem icon indicating copy to clipboard operation
CachingPlayerItem copied to clipboard

CachingPlayerItem crashes on iOS 14

Open MrdotSpock opened this issue 3 years ago • 12 comments

Hi,

Whenever I initialize CachingPlayerItem the app crashes because also override init(asset: AVAsset, automaticallyLoadedAssetKeys: [String]?) is called multiple times. But this initializer is not implemented. I tried to implement it myself but it creates a huge delay before the playing starts and I don't know which track I should play anyway.

This happens only on iOS 14. I've checked multiple times that I do not call the initializer myself and I really don't understand why it is happening. It seems like multiple instances of CachingPlayerItem are being created. (One with correct initializer and the rest with this one) Does anyone else also encounter this issue? Did anyone find a solution?

Thanks

MrdotSpock avatar Aug 31 '20 12:08 MrdotSpock

Same for me, crash appeared in analytics for all iOS14 users.

ealeksandrov avatar Aug 31 '20 12:08 ealeksandrov

I have the same problem ,it's not stable sometimes it crashes please help if you have find a solution ? i don't understand what happen in iOS 14 ! this is really odd

satyres avatar Sep 29 '20 20:09 satyres

same here, if anyone has a solution please help

kandhalarjan avatar Oct 14 '20 10:10 kandhalarjan

Hi has anyone tested on the iOS 14,2 ? please provide us your feedback so we can find a solution Regards

satyres avatar Dec 07 '20 11:12 satyres

This issue still persists on iOS 14.7 as well.

If I setup a playerItem -> CachingPlayerItem, and set it to some AVPlayer or AVQueuePlayer it plays fine.

but when I try to launch it for next cells/items in my pagerViewCotroller, it does not start download automatically and when user scrolls to next page or cell/item -> it crashes with fatalError breakpoint on line

override init(asset: AVAsset, automaticallyLoadedAssetKeys: [String]?) { fatalError("not implemented") }

Can we have a quick look into this.

Sulman012 avatar Jul 26 '21 09:07 Sulman012

+1 this is still broken.

It appears AVQueuePlayer and AVPlayerLooper are not compatible with this project

calsmith avatar Feb 04 '22 04:02 calsmith

I was able to solve this issue by adding override of the init it is complaining about:

override init(asset: AVAsset, automaticallyLoadedAssetKeys: [String]?) {
   self.url = URL(fileURLWithPath: "")
   super.init(asset: asset, automaticallyLoadedAssetKeys: automaticallyLoadedAssetKeys)
 }

Making sure to set empty URL before super.init call.

QEllis avatar Jul 15 '22 15:07 QEllis

i had to add these lines too for @QEllis 's answer:

override init(asset: AVAsset, automaticallyLoadedAssetKeys: [String]?) {
        self.url = URL(fileURLWithPath: "")
        self.initialScheme = nil
        super.init(asset: asset, automaticallyLoadedAssetKeys: automaticallyLoadedAssetKeys)
        
        addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions.new, context: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(playbackStalledHandler), name:NSNotification.Name.AVPlayerItemPlaybackStalled, object: self)
        
     }

dreampowder avatar Aug 03 '22 12:08 dreampowder

To everyone with this issue. When initializing your playerItem use:

let playerItem = CachePlayerItem(url: url, avUrlAssetOptions: nil) <<< make sure to set this to nil

This is the incorrect one to use and what causes the crash

let playerItem = CachePlayerItem(url: url) <<< DON'T USE THIS alone without the avUrlAssetOptions param

lsamaria avatar Oct 23 '22 21:10 lsamaria