iOS static Framework crash when animating view

Posted by user1439216 on Stack Overflow See other posts from Stack Overflow or by user1439216
Published on 2012-06-06T13:17:53Z Indexed on 2012/06/07 10:40 UTC
Read the original article Hit count: 765

Filed under:
|
|
|
|

I'm encountering a difficult to debug issue with a static library project when attempting to animate a view.
It works fine when debugging (and even when debugging in the release configuration), but throws an error archived as a release:

Exception Type:  EXC_CRASH (SIGSYS)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   TestApp                     0x000d04fc 0x91000 + 259324
1   UIKit                       0x336d777e +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 42
2   TestApp                     0x000d04de 0x91000 + 259294
3   TestApp                     0x000d0678 0x91000 + 259704
4   Foundation                  0x355f04f8 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 12
5   CoreFoundation              0x35aae540 ___CFXNotificationPost_block_invoke_0 + 64
6   CoreFoundation              0x35a3a090 _CFXNotificationPost + 1400
7   Foundation                  0x355643e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
8   UIKit                       0x33599112 -[UIInputViewTransition postNotificationsForTransitionStart] + 846
9   UIKit                       0x335988cc -[UIPeripheralHost(UIKitInternal) executeTransition:] + 880
10  UIKit                       0x3351bb8c -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 304
11  UIKit                       0x3351b260 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 952
12  UIKit                       0x3351ae54 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 160
13  UIKit                       0x3351a990 -[UIResponder becomeFirstResponder] + 452
14  UIKit                       0x336194a0 -[UITextInteractionAssistant setFirstResponderIfNecessary] + 168
15  UIKit                       0x33618d6a -[UITextInteractionAssistant oneFingerTap:] + 1602
16  UIKit                       0x33618630 _UIGestureRecognizerSendActions + 100
17  UIKit                       0x335a8d5e -[UIGestureRecognizer _updateGestureWithEvent:] + 298
18  UIKit                       0x337d9472 ___UIGestureRecognizerUpdate_block_invoke_0541 + 42
19  UIKit                       0x33524f4e _UIGestureRecognizerApplyBlocksToArray + 170
20  UIKit                       0x33523a9c _UIGestureRecognizerUpdate + 892
21  UIKit                       0x335307e2 _UIGestureRecognizerUpdateGesturesFromSendEvent + 22
22  UIKit                       0x33530620 -[UIWindow _sendGesturesForEvent:] + 768
23  UIKit                       0x335301ee -[UIWindow sendEvent:] + 82
24  UIKit                       0x3351668e -[UIApplication sendEvent:] + 350
25  UIKit                       0x33515f34 _UIApplicationHandleEvent + 5820
26  GraphicsServices            0x376d5224 PurpleEventCallback + 876
27  CoreFoundation              0x35ab651c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
28  CoreFoundation              0x35ab64be __CFRunLoopDoSource1 + 134
29  CoreFoundation              0x35ab530c __CFRunLoopRun + 1364
30  CoreFoundation              0x35a3849e CFRunLoopRunSpecific + 294
31  CoreFoundation              0x35a38366 CFRunLoopRunInMode + 98
32  GraphicsServices            0x376d4432 GSEventRunModal + 130
33  UIKit                       0x33544cce UIApplicationMain + 1074

Thread 0 crashed with ARM Thread State:
    r0: 0x0000004e    r1: 0x000d04f8      r2: 0x338fed47      r3: 0x3f523340
    r4: 0x00000000    r5: 0x2fe8da00      r6: 0x00000001      r7: 0x2fe8d9d0
    r8: 0x3f54cad0    r9: 0x00000000     r10: 0x3fd00000     r11: 0x3f523310
    ip: 0x3f497048    sp: 0x2fe8d988      lr: 0x33539a41      pc: 0x000d04fc
  cpsr: 0x60000010

To give some background info:
The static library is part of an 'iOS fake-framework', built using the templates from here:
https://github.com/kstenerud/iOS-Universal-Framework
The framework presents a registration UI as a modal view on top of whatever the client application is doing at the time. It pushes these views using a handle to a UIViewController provided by the client application.

It doesn't do anything special, but here's the animation code:

-(void)keyboardWillShowNotification:(NSNotification *)notification
{
    double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

    dispatch_async(dispatch_get_main_queue(), ^(void) {
        [self animateViewsToState:kUMAnimationStateKeyboardVisible forIdiom:[UIDevice currentDevice].userInterfaceIdiom forDuration:animationDuration];
    });
}

-(void)animateViewsToState:(kUMAnimationState)state forIdiom:(UIUserInterfaceIdiom)idiom forDuration:(double)duration
{
    float fieldOffset;    
    if (idiom == UIUserInterfaceIdiomPhone) {
        if (state == kUMAnimationStateKeyboardVisible) {
            fieldOffset = -KEYBOARD_HEIGHT_IPHONE_PORTRAIT;
        } else {
            fieldOffset = KEYBOARD_HEIGHT_IPHONE_PORTRAIT;
        }
    } else {
        if (state == kUMAnimationStateKeyboardVisible) {
            fieldOffset = -IPAD_FIELD_OFFSET;
        } else {
            fieldOffset = IPAD_FIELD_OFFSET;
        }
    }

    [UIView animateWithDuration:duration animations:^(void) {
        mUserNameField.frame = CGRectOffset(mUserNameField.frame, 0, fieldOffset);
        mUserPasswordField.frame = CGRectOffset(mUserPasswordField.frame, 0, fieldOffset);
    }];
}

Further printf-style debugging shows that it crashes whenever I do anything much with UIKit - specifically, it crashes when I replace -animateViewsToState with:

if (0 == UIUserInterfaceIdiomPhone) {
    NSLog(@"");
}

and

[[[[UIAlertView alloc] initWithTitle:@"test" message:@"123" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];

To me, this sounds like a linker problem, but I don't understand how such problems would only manifest here, and not beforehand.

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about ios

Related posts about animation