Search code examples
iosobjective-ciphonexcodelive-sdk

ios 8 + LiveSDK authentication crashes my app


I have an app in the store that use LiveSDK API to log the user into OneDrive. The last release was pushed before iOS8 came out, but it works without problem with iOS8

Now I want to push an update (unrelated to OneDrive features) and I am using xcode 6.1.1 but testing the app I noticed that every time the user is authenticated into OneDrive the app will crash as soon as return from a segue or flipside view to the Main View.

I was able to isolate the issue to this line added in viewDidLoad:

self.liveClient = [[LiveConnectClient alloc] initWithClientId:APP_CLIENT_ID
                                                             delegate:self
                                                            userState:@"initialize"];

and I really followed the basic instructions on how to login that can be found here:

http://msdn.microsoft.com/en-us/library/dn631822.aspx#sign_the_user_in

The steps to reproduce the issue (on both thee device and the simulator) are the following:

a) app starts b) click to the cloud service login button that will trigger a flipsideviewcontroller c) log into OneDrive with the code provided by MS d) go back to the main controller e) CRASH!

The trace is the following:

#########################################################
*** First throw call stack:
(
    0   CoreFoundation                      0x028dd1e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x026598e5 objc_exception_throw + 44
    2   CoreFoundation                      0x0297a243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x028cd50b ___forwarding___ + 1019
    4   CoreFoundation                      0x028cd0ee _CF_forwarding_prep_0 + 14
    5   CloudFella                          0x0015c867 -[LiveConnectClientCore dealloc] + 48
    6   libobjc.A.dylib                     0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
    7   libobjc.A.dylib                     0x0266baeb -[NSObject release] + 25
    8   CloudFella                          0x00158af1 -[LiveConnectClient dealloc] + 44
    9   libobjc.A.dylib                     0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
    10  libobjc.A.dylib                     0x02669e81 objc_release + 49
    11  libobjc.A.dylib                     0x02669e3e objc_storeStrong + 39
    12  CloudFella                          0x00157b9d -[CFFlipsideViewController .cxx_destruct] + 249
    13  libobjc.A.dylib                     0x026582d4 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 128
    14  libobjc.A.dylib                     0x0265824f object_cxxDestruct + 20
    15  libobjc.A.dylib                     0x0266327a objc_destructInstance + 48
    16  libobjc.A.dylib                     0x026632ab object_dispose + 20
    17  UIKit                               0x01433d1a -[UIViewController dealloc] + 1854
    18  UIKit                               0x01430915 -[UIViewController release] + 89
    19  libobjc.A.dylib                     0x02669e97 objc_release + 71
    20  libobjc.A.dylib                     0x02656bf0 objc_setProperty_nonatomic + 48
    21  UIKit                               0x01a6167d -[_UIViewControllerOneToOneTransitionContext _setFromViewController:] + 47
    22  UIKit                               0x01a61490 -[_UIViewControllerOneToOneTransitionContext dealloc] + 43
    23  libobjc.A.dylib                     0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
    24  libobjc.A.dylib                     0x0266baeb -[NSObject release] + 25
    25  UIKit                               0x01a60834 -[_UIViewControllerTransitionContext completeTransition:] + 135
    26  UIKit                               0x01a7a5b1 -[UIViewControllerBuiltinTransitionViewAnimator transitionViewDidComplete:fromView:toView:removeFromView:] + 50
    27  UIKit                               0x01416137 -[UITransitionView notifyDidCompleteTransition:] + 345
    28  UIKit                               0x01415e61 -[UITransitionView _didCompleteTransition:] + 1333
    29  UIKit                               0x014181b7 -[UITransitionView _transitionDidStop:finished:] + 107
    30  UIKit                               0x013666dc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
    31  UIKit                               0x013669c8 -[UIViewAnimationState animationDidStop:finished:] + 80
    32  QuartzCore                          0x00fd6bb4 _ZN2CA5Layer23run_animation_callbacksEPv + 304
    33  libdispatch.dylib                   0x0326b4d0 _dispatch_client_callout + 14
    34  libdispatch.dylib                   0x03259726 _dispatch_main_queue_callback_4CF + 340
    35  CoreFoundation                      0x0294243e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    36  CoreFoundation                      0x028835cb __CFRunLoopRun + 1963
    37  CoreFoundation                      0x028829d3 CFRunLoopRunSpecific + 467
    38  CoreFoundation                      0x028827eb CFRunLoopRunInMode + 123
    39  GraphicsServices                    0x0301f5ee GSEventRunModal + 192
    40  GraphicsServices                    0x0301f42b GSEventRun + 104
    41  UIKit                               0x01316f9b UIApplicationMain + 1225
    42  CloudFella                          0x000eeea6 main + 94
    43  libdyld.dylib                       0x034af6d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
#

If I log into the other cloud services available in my app (Google drive , dropbox, evernote) I got no issues at all.

The problem is happening with both the old LiveSDK API (the one included in the current good release out in the store) and the newest build (2 months old) added to the app to solve some validation issues described here: https://github.com/liveservices/LiveSDK-for-iOS/issues/43

I suspect that going from Xcode 5 to xcode 6 something changed in the building parameters that is causing the issue, however I am not sure where the issue is and how to workaround.

As test I forced building the app for 32 bit architectures only but it crashed as well: this was expected as the LiveSDK API is compatible with 64 bit arch, but certainly wanted to try... .

Any help is greatly appreciated.

Thanks, dom


Solution

  • Turns out this may be indeed a bug on the liveSDK.

    Opened the following issue:

    https://github.com/liveservices/LiveSDK-for-iOS/issues/53

    and another API user (https://github.com/sylverb) that ran into the same issue gave me a good workaround until the bug is fixed:

    "It was crashing because of "[authRefreshRequest cancel];" in the release method of LiveConnectClientCore.m . I had a temporary fix by adding "self" at this line in refreshSessionWithDelegate method (also in LiveConnectClientCore.m) :

     self.authRefreshRequest = [[[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
                                                                         scope:_scopes
                                                                  refreshToken:refreshToken
                                                                      delegate:delegate
                                                                     userState:userState
                                                                    clientStub:self]
                              autorelease];
    

    "

    Closing the post as solved because a workaround is provided and I added a link to the open bug opened for any other user that wants to follow up on this issue.