EXC_BREAKPOINT - libobjc.A.dylib object_getClass Crash on the main thread

Having an issue with crashes on iOS 16 and iOS 17 devices. App works and will appear to operate normally. However after a while the app will crash with a EXC_BREAKPOINT on libobjc.A.dylib object_getClass. The root cause seems to be something related to UIViews/Core Animation, I think. However the root crash trigger seems to be a half a dozen different triggers from the UI on main thread. It also only triggers on release builds, or the dev builds take a lot longer to trigger to the point it's very difficult to reproduce.

Here are some examples of the crashes occurring.

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0xe838 object_getClass + 48
1  Foundation                     0x1c854 _NSKeyValueObservationInfoGetObservances + 264
2  Foundation                     0x1bd1c NSKeyValueWillChangeWithPerThreadPendingNotifications + 232
3  QuartzCore                     0x59408 CAAnimation_setter(CAAnimation*, unsigned int, _CAValueType, void const*) + 128
4  QuartzCore                     0x749b4 -[CAAnimation setBeginTime:] + 52
5  QuartzCore                     0x728b4 CA::Layer::commit_animations(CA::Transaction*, double (*)(CA::Layer*, double, void*), void (*)(CA::Layer*, CA::Render::Animation*, void*), void (*)(CA::Layer*, __CFString const*, void*), CA::Render::TimingList* (*)(CA::Layer*, void*), void*) + 740
6  QuartzCore                     0x2aeac invocation function for block in CA::Context::commit_transaction(CA::Transaction*, double, double*) + 148
7  QuartzCore                     0x2adb4 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 368
8  QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
9  QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
10 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
11 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
12 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
13 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
14 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
15 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
16 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
17 QuartzCore                     0x2ad40 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
18 QuartzCore                     0x6f548 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 11192
19 QuartzCore                     0x65e3c CA::Transaction::commit() + 648
20 UIKitCore                      0x924cc _afterCACommitHandler + 84
21 CoreFoundation                 0x3583c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
22 CoreFoundation                 0x34244 __CFRunLoopDoObservers + 548
23 CoreFoundation                 0x33960 __CFRunLoopRun + 1028
24 CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
25 GraphicsServices               0x34f8 GSEventRunModal + 164
26 UIKitCore                      0x22c62c -[UIApplication _run] + 888
27 UIKitCore                      0x22bc68 UIApplicationMain + 340
0  libobjc.A.dylib                0x5d94 object_getClass + 48
1  Foundation                     0xadb8 _NSKeyValueObservationInfoGetObservances + 248
2  Foundation                     0x3f670 NSKeyValueWillChangeWithPerThreadPendingNotifications + 232
3  QuartzCore                     0xbb18 CAAnimation_setter(CAAnimation*, unsigned int, _CAValueType, void const*) + 128
4  QuartzCore                     0xcc14 -[CAPropertyAnimation setKeyPath:] + 52
5  QuartzCore                     0xcbc0 +[CAPropertyAnimation animationWithKeyPath:] + 36
6  UIKitCore                      0xc89fb0 -[UIMorphingLabel animateGlyph:toScale:delay:] + 308
7  UIKitCore                      0xc8a1fc -[UIMorphingLabel animateShowGlyph:alpha:alphaDuration:delay:] + 196
8  UIKitCore                      0xc8b3f0 -[UIMorphingLabel animateSubstitutionAlignmentHunkAtIndex:] + 1068
9  UIKitCore                      0x42cd84 -[UIMorphingLabel animateGlyphs] + 276
10 UIKitCore                      0xa374 -[UIMorphingLabel layoutSubviews] + 368
11 UIKitCore                      0x4420 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1992
12 QuartzCore                     0x9f30 CA::Layer::layout_if_needed(CA::Transaction*) + 500
13 QuartzCore                     0x1d4ac CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
14 QuartzCore                     0x2e8d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444
15 QuartzCore                     0x5de80 CA::Transaction::commit() + 648
16 QuartzCore                     0x47df0 CA::Transaction::flush_as_runloop_observer(bool) + 88
17 CoreFoundation                 0x90234 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
18 CoreFoundation                 0x1a410 __CFRunLoopDoObservers + 532
19 CoreFoundation                 0x7a19c __CFRunLoopRun + 1028
20 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
21 GraphicsServices               0x135c GSEventRunModal + 164
22 UIKitCore                      0x39cf58 -[UIApplication _run] + 888
23 UIKitCore                      0x39cbbc UIApplicationMain + 340

I'm at a loss, I'm clearly doing something wrong in the UIView/Core Animation side of things. Would be very grateful for anyone who can point me in the right direction.

Post not yet marked as solved Up vote post of obriena Down vote post of obriena
979 views

Replies

Is there any chance an object is getting released unexpectedly? Also it would be worth being sure the animation is all on the main thread.

Could be. I have run the app against Profiler and checked for leaks but haven't come up with any clues. Ran it through the Static Analyzer, + Running with Main Thread checker, Address Sanitizer, Thread Sanitizer as well Zombie Objects. Again no clues. Nothing that points towards the animations being the cause. I have double checked the half dozen animations I have done in my app, believe that I that they should all be running on the Main Thread.

I also encountered the same problem after I upgraded to Xcode 15.0, where I started experiencing crashes related to CoreAnimation. The crashes occur randomly, which is very annoying. I tried disabling implicit animations on many layers, which significantly reduced the frequency of the crashes. However, this is not a long-term solution.

Thanks @kobunketsu. The app I'm working on only uses less than a dozen block based animations. I keep looking for what we've done wrong to trigger it this behaviour, because surely not every app which uses Core Animation is crashing with this regularity. But you are right the crashes started happening in mid October with our Xcode 15 build. What sort of reduction of the crashes did you get from disabling the implicit animations?

  • Are you using the MBProgressHUD? I may have found a potential cause of the crash, if MBProgressHUD is initialized with blur style and UIVisualEffectView is added, if I call some UI operation at the same time, the application will call -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey after UIVisualEffectView receives dealloc call :], which may have caused the crash shown on the stack. I'm not 100% sure since crashes happen rarely, but I've observed this in instruments.

Add a Comment

I used this method when setting the layer's properties like .frame, to prevent implict frame animation from being called. @implementation CALayer (Animation)

  • (void)disableAnimation:(VoidBlock)block{ [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; block(); [CATransaction commit];

} @end

Please read this post:, I think this is a bug on iOS17. I have no choice, but downgrade to Xcode14.3.1 and iOS16, stay away from current version of iOS17. Now the crash disappears.

Any updates on this crash?