Fabrizio Bartolomucci
Fabrizio Bartolomucci

Reputation: 4948

iOS app crashing with cfrunloop_is_calling_out_to_an_observer_callback_function

When running my app I occasionally get this crash that seems not to have anything with my code. What is it and how my I avert it?

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x000000018fc4c16c mach_msg_trap + 8 1 libsystem_kernel.dylib
0x000000018fc4bfdc mach_msg + 72 2 AudioToolbox
0x0000000193c8bcdc ASClient_AudioSessionSetActiveWithFlags + 132 3
AudioToolbox 0x0000000193c6c7f4 AudioSessionSetActive_Priv + 360 4 AVFAudio
0x00000001aa46bf8c -[AVAudioSession setActive:withOptions:error:] + 84 5 Jam Session 0x00000001000d41b8 0x1000b0000 + 147896 6 Jam Session 0x00000001000d53fc 0x1000b0000 + 152572 7 UIKit
0x0000000196ae90ec -[UIViewController loadViewIfRequired] + 1056 8
UIKit 0x0000000196ba2cdc -[UINavigationController _layoutViewController:] + 72 9 UIKit 0x0000000196ba2bb4 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 416 10 UIKit 0x0000000196ba1efc -[UINavigationController _startTransition:fromViewController:toViewController:] + 140 11 UIKit 0x0000000196ba1948 -[UINavigationController _startDeferredTransitionIfNeeded:] + 856 12 UIKit 0x0000000196ba14fc -[UINavigationController viewWillLayoutSubviews] + 64 13 UIKit 0x0000000196ba1460 -[UILayoutContainerView layoutSubviews] + 188 14 UIKit 0x0000000196ae625c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1196 15 QuartzCore 0x0000000193fad2c8 -[CALayer layoutSublayers] + 148 16 QuartzCore
0x0000000193fa1fa4 CA::Layer::layout_if_needed(CA::Transaction*) + 292 17 QuartzCore 0x0000000193fa1e64 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32 18 QuartzCore 0x0000000193f1eb20 CA::Context::commit_transaction(CA::Transaction*) + 252 19 QuartzCore 0x0000000193f45f8c CA::Transaction::commit() + 512 20 QuartzCore
0x0000000193f469ac CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120 21 CoreFoundation
0x0000000190c4a7dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 32 22 CoreFoundation 0x0000000190c4840c __CFRunLoopDoObservers + 372 23 CoreFoundation 0x0000000190b77068 CFRunLoopRunSpecific + 476 24 UIKit
0x0000000196b542ec -[UIApplication _run] + 608 25 UIKit
0x0000000196b4f070 UIApplicationMain + 208 26 Jam Session
0x00000001000c36d4 0x1000b0000 + 79572 27 libdyld.dylib
0x000000018fb585b8 start + 4

Upvotes: 9

Views: 7871

Answers (2)

Declan Land
Declan Land

Reputation: 650

I came across this issue today after subclassing a UIView. To resolve this I did the following:

  • Add an Exception Breakpoint for all exceptions
  • Enable Zombie Objects

After viewing the thread stack on the left pane, I noticed something related to "key path" and "value".. then I realised that when creating my subclass, I'd created an IBInspectable and updated this value in the storyboard. I later removed this and this is what caused the crash, because the class was still trying to set this value at runtime.

So make sure to check your "User Defined Runtime Attributes".

Upvotes: 3

Annie Gupta
Annie Gupta

Reputation: 2822

This crash occurs when using NSNotificationCenter

You registered a notification observer to an object that has been released and didn't removed the observer. So when it tries to call the selector it crashes.

If you are using a ViewController of some kind, you can add

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"Notification" object:nil];

to the viewWillDisappear

if it is not a ViewController you can use -(void) dealloc to unregister the Observer.

In case you to debug further to exactly figure out the point of origin of crash. Put an exception breakpoint in the breakpoints tab and run the app, do casual testing and see if you get the crash.

This should work..

Cheers!

Upvotes: 0

Related Questions