MillmanY / MMPlayerView

Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Crash 0n MMPlayerView Version 5.1.1 and iOS 13

mohit196 opened this issue · comments

Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <_NSKeyValueObservation 0x282f08450> for the key path "status" from <MMPlayerView.MMPlayerItem 0x2837a6400> because it is not registered as an observer.'

Are you aware of it?

Thanks

same issue happen in ios 13 in my project also but not got any solution

@mohit196 Have u got any solution ?

not yet...I will post here the second I found anything.

same issue @mohit196 have you got any solution.
'NSRangeException', reason: 'Cannot remove an observer < 0x7ff9f6547250> for the key path "status" from <MMPlayerView.MMPlayerLayer 0x7ff9f674ee00> because it is not registered as an observer.'

same issue @mohit196 have you got any solution.
'NSRangeException', reason: 'Cannot remove an observer < 0x7ff9f6547250> for the key path "status" from <MMPlayerView.MMPlayerLayer 0x7ff9f674ee00> because it is not registered as an observer.'

Hi guys, I installed Xcode 11 and in my case , crashed in videoRect observation but status fine.
I will check the issue

I creat A New ViewController and Push to NavigationController,I use the MMPlayerView in this New Viewcontroller .when I pop to the last Viewcontroller , crashed happened

I know where crashed, but in ios12 work fine so let me think about how to fix it

New Crash,MMPlayerView.MMPlayerLayer was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x283d363a0> (
<NSKeyValueObservance 0x2833285d0: Observer: 0x2833291d0, Key path: videoRect, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x2833921c0>
)

In my case app is crashing when one video ends and I am trying to play the next video...I am initiating next video call from the end status with a delay of 0.25 sec if this helps.

Getting Crash when pop to controller: - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7f8bc259f510 of class MMPlayerView.MMPlayerLayer was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x600003060900> (
<NSKeyValueObservance 0x600003e7d5f0: Observer: 0x600003e351d0, Key path: videoRect, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x600003e551d0>

I know where crashed, but in ios12 work fine so let me think about how to fix it

Are you going to fix it soon?

Give me some times, I need to check its not a bug in ios 13

@MillmanY any luck.?

The problem is with this line: self.removeObserver(observer, forKeyPath: "status")
Just remove it. observer.invalidate() is enough to unregister the observer. It should work fine.

Crash on this

 videoRectObservation = self.observe(\.videoRect, options: [.new, .old]) { [weak self] (player, change) in
        if change.newValue != change.oldValue {
            self?.updateCoverConstraint()
        }
 }

I fix to use original kvo registered function, so I think is a bug on ios

    self.addObserver(self, forKeyPath: "videoRect", options: [.new, .old], context: nil)

override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    
    switch keyPath {
    case "videoRect", "frame", "bounds":
        let new = change?[.newKey] as? CGRect ?? .zero
        let old = change?[.oldKey] as? CGRect ?? .zero
        if new != old {
            self.updateCoverConstraint()
        }
        
    case "muted":
        let new = change?[.newKey] as? Bool ?? false
        let old = change?[.oldKey] as? Bool ?? false
        if new != old {
            self.coverView?.player?(isMuted: new)
        }
    case "rate":
        let new = change?[.newKey] as? Float ?? 1.0
        let status = self.currentPlayStatus
        switch status {
        case .playing, .pause, .ready:
            self.currentPlayStatus = (new == 0.0) ? .pause : .playing
        case .end:
            let total = self.player?.currentItem?.duration.seconds ?? 0.0
            let current = self.player?.currentItem?.currentTime().seconds ?? 0.0
            if current < total {
                self.currentPlayStatus = (new == 0.0) ? .pause : .playing
            }
        default: break
        }

    default:
        super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
    }
}

Fix on pod 5.1.2

Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <_NSKeyValueObservation 0x282f08450> for the key path "status" from <MMPlayerView.MMPlayerItem 0x2837a6400> because it is not registered as an observer.'

Are you aware of it?

Thanks

Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <_NSKeyValueObservation 0x280d74bb0> for the key path "videoRect" from <MMPlayerView.MMPlayerLayer 0x10d91860

Same issue Occurs in Xcode 11.2

Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <AudioPlayer 0x281f5b9c0> for the key path "status" from <IndexedPlayerItem 0x28267f880> because it is not registered as an observer.

why happend this when clipping in just audio package flutter