When playing video Content : KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECTS_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED

When i am playing video got this crash.

Crashlytics log reports


Crashed: com.apple.main-thread

0 libobjc.A.dylib 0x1845a67e8 object_isClass + 16

1 Foundation 0x185d103e8 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 68

2 Foundation 0x185d0e8ec NSKeyValueWillChangeWithPerThreadPendingNotifications + 300

3 AVFoundation 0x18abb60f8 -[AVPlayerItem willChangeValueForKey:] + 96

4 AVFoundation 0x18abc7ff0 -[AVPlayerItem _updatePropertyCacheAndTriggerKVOForPlayer:usingKeys:] + 200

5 AVFoundation 0x18abb959c __60-[AVPlayerItem _informObserversAboutAvailabilityOfDuration:]_block_invoke_2 + 184

6 libdispatch.dylib 0x184cdd088 _dispatch_call_block_and_release + 24

7 libdispatch.dylib 0x184cdd048 _dispatch_client_callout + 16

8 libdispatch.dylib 0x184d1ddfc _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 968

9 CoreFoundation 0x185301eb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12

10 CoreFoundation 0x1852ffa8c __CFRunLoopRun + 2012

11 CoreFoundation 0x18521ffb8 CFRunLoopRunSpecific + 436

12 GraphicsServices 0x1870b7f84 GSEventRunModal + 100

13 UIKit 0x18e7f42f4 UIApplicationMain + 208

14 VZFiOSMobile 0x10475b340 main (main.m:17)

15 libdyld.dylib 0x184d4256c start + 4


Why does this happens and what I can do to avoid this?

Replies

I also get this! I am looking for a solution too, if I find I will update you, please update me too if you find the solution.


Thanks!

Hi guys,


we have the same issue. Double cheked in code to confirm that we don't observe AVPlayerItem manually.


Do you use Conviva or Irdeto player by any chance?


Stacktrace is


Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000fa4fbec8


0 libobjc.A.dylib 0x18588a7e8 object_isClass + 16

1 Foundation 0x187007fe0 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 68

2 Foundation 0x1870064bc NSKeyValueWillChangeWithPerThreadPendingNotifications + 300

3 AVFoundation 0x18bf21f78 -[AVPlayerItem willChangeValueForKey:] + 96

4 AVFoundation 0x18bf33e70 -[AVPlayerItem _updatePropertyCacheAndTriggerKVOForPlayer:usingKeys:] + 200

5 AVFoundation 0x18bf39564 __avplayeritem_fpItemNotificationCallback_block_invoke + 2076

6 libdispatch.dylib 0x185fc2a54 _dispatch_call_block_and_release + 24

7 libdispatch.dylib 0x185fc2a14 _dispatch_client_callout + 16

8 libdispatch.dylib 0x185fcf698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016

9 CoreFoundation 0x1865ee544 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12

10 CoreFoundation 0x1865ec120 __CFRunLoopRun + 2012

11 CoreFoundation 0x18650be58 CFRunLoopRunSpecific + 436

I've started seeing it too while playing audio with AVPlayer. Anyone found a solution yet?

Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x000000018de864ac objectisClass + 16 (objc-runtime-new.h:340)
1 Foundation 0x000000018e5145f8 KVO
ISRETAININGALLOBSERVERSOFTHISOBJECTIFITCRASHESANOBSERVERWASOVERRELEASEDORSMASHED + 44 (NSKeyValueObserving.m:1120)
2 Foundation 0x000000018e512120 NSKeyValueWillChangeWithPerThreadPendingNotifications + 272 (NSKeyValueObserving.m:1151)
3 AVFoundation 0x000000019836e84c
avplayeritemfpItemNotificationCallbackblockinvoke + 2652 (AVPlayerItem.m:9045)
4 libdispatch.dylib 0x000000018de2a9a8 dispatchcallblockandrelease + 24 (init.c:1408)
5 libdispatch.dylib 0x000000018de2b524
dispatchclientcallout + 16 (object.m:495)
6 libdispatch.dylib 0x000000018de0e6fc dispatchmainqueuecallback4CF$VARIANT$armv81 + 860 (inlineinternal.h:2484)
7 CoreFoundation 0x000000018e0e37fc CFRUNLOOPISSERVICINGTHEMAINDISPATCHQUEUE + 12 (CFRunLoop.c:1749)
8 CoreFoundation 0x000000018e0de6d0 __CFRunLoopRun + 1724 (CFRunLoop.c:3069)
9 CoreFoundation 0x000000018e0ddce8 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
10 GraphicsServices 0x000000019822838c GSEventRunModal + 160 (GSEvent.c:2246)
11 UIKitCore 0x000000019220c444 UIApplicationMain + 1932 (UIApplication.m:4823)
12 HitReview 0x00000001007dc768 main + 68 (Chart+CoreDataProperties.swift:19)
13 libdyld.dylib 0x000000018df658f0 start + 4

A common cause of these types of crashes is forgetting to unregister your observer from KVO before that observer is deallocated.
Even I am getting this. No idea what I am doing wrong.
A common cause of these types of crashes is forgetting to unregister your observer from KVO before that observer is deallocated.

I try this but still getting crash --

It's related to KVO = Key-Value Observing. Check if you're calling the function object.addObserver(self, forKeyPath:..., options:..., context:...) somewhere; that's your KVO observer. This class would also override the function observeValue(forKeyPath:of:change:context:) As the error message says, if you get a crash here, that means the observer was "overreleased" or "smashed". I think that just means it was released while still observing the key path.

Observing the same issue, while I click I am adding the new player once after removing all the observers, but still able to reproduce the same issue. This issue occurs only after 3-4 correct functioning. Thanks for the help.

0   CoreFoundation                      0x00000001803f41fc __exceptionPreprocess + 236

1   libobjc.A.dylib                     0x000000018016a438 objc_exception_throw + 56

2   AVFCore                             0x00000001b58e98bc __32-[AVPlayerItem _attachToPlayer:]_block_invoke + 0

3   AVFCore                             0x00000001b58cf274 -[AVPlayer _insertItem:afterItem:] + 56

4   SelfLearn                           0x0000000100dead44 $s9SelfLearn0aB11VideoPlayerC18playerEndedPlaying33_783A90EB63367B572AA588642046C941LLyy10Foundation12NotificationVFyycfU_ + 988

5   SelfLearn                           0x0000000100c06bd8 $sIeg_IeyB_TR + 52

6   libdispatch.dylib                   0x000000010276f764 _dispatch_call_block_and_release + 24

7   libdispatch.dylib                   0x0000000102770f34 _dispatch_client_callout + 16

8   libdispatch.dylib                   0x000000010277f674 _dispatch_main_queue_callback_4CF + 1048

9   CoreFoundation                      0x0000000180362ef4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12

10  CoreFoundation                      0x000000018035d428 __CFRunLoopRun + 2444

11  CoreFoundation                      0x000000018035c58c CFRunLoopRunSpecific + 572

12  GraphicsServices                    0x000000018b634740 GSEventRunModal + 160

13  UIKitCore                           0x00000001843c5cbc -[UIApplication _run] + 964

14  UIKitCore                           0x00000001843caa9c UIApplicationMain + 112

15  libswiftUIKit.dylib                 0x00000001b1d9a328 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100

16  SelfLearn                           0x0000000100e1c9e0 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 120

17  SelfLearn                           0x0000000100e1c958 $s9SelfLearn11AppDelegateC5$mainyyFZ + 48

18  SelfLearn                           0x0000000100e1ca24 main + 32

19  libdyld.dylib                       0x0000000180221cbc start + 4

)

libc++abi.dylib: terminating with uncaught exception of type NSException

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem cannot be associated with more than one instance of AVPlayer'

I had this crash, but when I checked I had two cleanup paths. This led to the player and playerItem being deallocated before playerItem?.removeObserver or player?.removeObserver were called in deinit, hence the observers were not being removed.