iosuiviewanimationcrash-reportscclayer

Random Crash with CA::Layer::set_position


I have a crashing bug in my app.

It happens in the same place, but not all the time. I haven't found the problem.

Here are two crash logs:

    Incident Identifier: EB73AE61-00FB-4282-8F1D-B8ECEC19E02D
CrashReporter Key:   6f005b28e796b18f3ab2687bb364b2be1eb137cd
Hardware Model:      iPhone5,2
Path:            /var/mobile/Applications/BF2F1016-8C00-40A3-BB75-0933F53741F0/*******.app/******
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0

Last Exception Backtrace:
0   CoreFoundation                    0x312d13e2 __exceptionPreprocess + 158
1   libobjc.A.dylib                   0x38fc295e objc_exception_throw + 26
2   CoreFoundation                    0x312d1302 +[NSException raise:format:] + 102
3   QuartzCore                        0x32e8e106 CA::Layer::set_position(CA::Vec2<double> const&, bool) + 206
4   QuartzCore                        0x32e8e02e -[CALayer setPosition:] + 46
5   QuartzCore                        0x32e8dfc2 -[CALayer setFrame:] + 554
6   UIKit                             0x330e1bd2 -[UIView(Geometry) setFrame:] + 230
7   UIKit                             0x330e18fc -[UIImageView _setViewGeometry:forMetric:] + 180
8   UIKit                             0x330e183a -[UIImageView setFrame:] + 42
9   etapes                            0x0006de1c 0x5c000 + 73244
10  UIKit                             0x33203136 -[UIScrollView _endPanWithEvent:] + 3694
11  UIKit                             0x3321c520 -[UIScrollView handlePan:] + 120
12  UIKit                             0x331fdc5c _UIGestureRecognizerSendActions + 124
13  UIKit                             0x331c539c -[UIGestureRecognizer _updateGestureWithEvent:] + 388
14  UIKit                             0x333b215e ___UIGestureRecognizerUpdate_block_invoke_0543 + 42
15  UIKit                             0x330e987e _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 214
16  UIKit                             0x330e82c8 _UIGestureRecognizerUpdate + 1160
17  UIKit                             0x330f31e2 -[UIWindow _sendGesturesForEvent:] + 762
18  UIKit                             0x330f2dae -[UIWindow sendEvent:] + 86
19  UIKit                             0x330e08dc -[UIApplication sendEvent:] + 376
20  UIKit                             0x330e01ea _UIApplicationHandleEvent + 6194
21  GraphicsServices                  0x34df75f2 _PurpleEventCallback + 586
22  GraphicsServices                  0x34df7222 PurpleEventCallback + 30
23  CoreFoundation                    0x312a63e2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
24  CoreFoundation                    0x312a6386 __CFRunLoopDoSource1 + 134
25  CoreFoundation                    0x312a520a __CFRunLoopRun + 1378
26  CoreFoundation                    0x31218238 CFRunLoopRunSpecific + 352
27  CoreFoundation                    0x312180c4 CFRunLoopRunInMode + 100
28  GraphicsServices                  0x34df6336 GSEventRunModal + 70
29  UIKit                             0x331342b4 UIApplicationMain + 1116
30  etapes                            0x0005e15e 0x5c000 + 8542
31  etapes                            0x0005e114 0x5c000 + 8468

//////////////////////////// SECOND CRASH LOG ///////////////////////////////////

Incident Identifier: 4FE03135-D442-4CEA-B230-8322647262EE
CrashReporter Key:   6f005b28e796b18f3ab2687bb364b2be1eb137cd
Hardware Model:      iPhone5,2
Process:         etapes [2916]
Path:            /var/mobile/Applications/BF2F1016-8C00-40A3-BB75-0933F53741F0/******.app/****
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000064
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   UIKit                             0x33df7b06 -[UIView(CALayerDelegate) actionForLayer:forKey:] + 138
1   QuartzCore                        0x33ba7786 -[CALayer actionForKey:] + 70
2   QuartzCore                        0x33ba7732 _ZL12actionForKeyP7CALayerPN2CA11TransactionEP8NSString + 54
3   QuartzCore                        0x33ba7626 CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*&) + 126
4   QuartzCore                        0x33ba2322 CA::Layer::setter(unsigned int, _CAValueType, void const*) + 178
5   QuartzCore                        0x33bce782 -[CALayer setBackgroundColor:] + 30
6   UIKit                             0x33e0ef50 -[UIView(Internal) _setBackgroundCGColor:withSystemColorName:] + 1016
7   etapes                            0x000fc8d2 0xdd000 + 129234
8   etapes                            0x000f8c6a 0xdd000 + 113770
9   CoreFoundation                    0x31fe9ad0 __invoking___ + 64
10  CoreFoundation                    0x31f4128a -[NSInvocation invoke] + 286
11  Foundation                        0x328eaf60 -[NSInvocationOperation main] + 108
12  Foundation                        0x32874a84 -[__NSOperationInternal start] + 836
13  Foundation                        0x328ecfe2 __block_global_6 + 98
14  libdispatch.dylib                 0x3a0f1790 _dispatch_call_block_and_release + 8
15  libdispatch.dylib                 0x3a0f15d8 _dispatch_client_callout + 20
16  libdispatch.dylib                 0x3a0f4e40 _dispatch_main_queue_callback_4CF + 224
17  CoreFoundation                    0x31fba1ac __CFRunLoopRun + 1284
18  CoreFoundation                    0x31f2d238 CFRunLoopRunSpecific + 352
19  CoreFoundation                    0x31f2d0c4 CFRunLoopRunInMode + 100
20  GraphicsServices                  0x35b0b336 GSEventRunModal + 70
21  UIKit                             0x33e492b4 UIApplicationMain + 1116
22  etapes                            0x000df15e 0xdd000 + 8542
23  etapes                            0x000df114 0xdd000 + 8468

If you want more details, I'm available!

after research, here is the code that is the problem :

self.imageviewFondArticle.frame = CGRectMake((-((_imageviewFondArticle.frame.size.height*imageRatio)-320)/2),0, _imageviewFondArticle.frame.size.height*imageRatio, _imageviewFondArticle.frame.size.height);

Solution

  • First, CALayer's "frame" is a "computed property" according to Apple's docs. You may want to be setting the bounds, anchorPoint or position properties. (In contrast, UIView's frame can be set and animated.)

    Second, I came to this post 'cos I encountered such a crash as well. It happened when I was setting a CALayer's position property. It turned out that the exception thrown was for an invalid position - one of the coordinates was NaN. I found this by wrapping the "layer.position = pos" in a @try-@catch block. Fixing the root cause of the invalid position solved the problem for me. Based on this, I would guess that you have an invalid "imageRatio" value.