Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on iOS #123

Closed
barocsi opened this issue Apr 25, 2016 · 7 comments
Closed

Crash on iOS #123

barocsi opened this issue Apr 25, 2016 · 7 comments

Comments

@barocsi
Copy link

barocsi commented Apr 25, 2016

Just updated the plugin in iOS. On Android it works.
It happens immediately after returning from a successful Facebook plugin login.
Using https://github.com/jeduan/cordova-plugin-facebook4/

2016-04-25 22:43:42.880 testapp[18570:935790] THREAD WARNING: ['FacebookConnectPlugin'] took '31.369873' ms. Plugin should use a background thread.
2016-04-25 22:43:42.896 testapp[18570:935790] Starting login
2016-04-25 22:43:42.928 testapp[18570:935790] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2016-04-25 22:43:42.957 testapp[18570:935790] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2016-04-25 22:43:43.229 testapp[18570:935790] THREAD WARNING: ['FacebookConnectPlugin'] took '332.930664' ms. Plugin should use a background thread.
2016-04-25 22:43:49.570 testapp[18570:935790] inside initSessionAndRegisterDeepLinkHandler block
2016-04-25 22:43:49.571 testapp[18570:935790] Success
2016-04-25 22:43:49.572 testapp[18570:935790] returning data to js interface..
2016-04-25 22:43:49.573 testapp[18570:935790] Sending to JS: {
    "+clicked_branch_link" = 0;
    "+is_first_session" = 0;
}
2016-04-25 22:43:49.631 testapp[18570:935790] WARNING: GoogleAnalytics 3.14 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:48): Uncaught exception: Invalid type in JSON write (NSURL)
2016-04-25 22:43:50.932 testapp[18570:935790] start setIdentity
2016-04-25 22:43:50.933 testapp[18570:935790] start getInstance
2016-04-25 22:43:50.950 testapp[18570:935790] inside setIdentity block
2016-04-25 22:43:50.950 testapp[18570:935790] returning data to js interface..
2016-04-25 22:43:50.950 testapp[18570:935790] THREAD WARNING: ['BranchSDK'] took '17.984863' ms. Plugin should use a background thread.
2016-04-25 22:43:54.659 testapp[18570:935790] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSURL)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00680494 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x04845e02 objc_exception_throw + 50
    2   CoreFoundation                      0x006803bd +[NSException raise:format:] + 141
    3   Foundation                          0x0457c6a4 _writeJSONValue + 799
    4   Foundation                          0x04580951 ___writeJSONObject_block_invoke + 229
    5   CoreFoundation                      0x005d7d8c __65-[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 76
    6   CoreFoundation                      0x005d7c54 -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 180
    7   CoreFoundation                      0x00597215 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
    8   Foundation                          0x045800d3 _writeJSONObject + 407
    9   Foundation                          0x0457c5a5 _writeJSONValue + 544
    10  Foundation                          0x0457c33d -[_NSJSONWriter dataWithRootObject:options:error:] + 125
    11  Foundation                          0x0457f3d1 +[NSJSONSerialization dataWithJSONObject:options:error:] + 371
    12  testapp                           0x000f004f -[BranchSDK postUnhandledURL:] + 463
    13  Foundation                          0x044edb86 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 40
    14  CoreFoundation                      0x00645264 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    15  CoreFoundation                      0x00644f1a _CFXRegistrationPost + 458
    16  CoreFoundation                      0x00644c66 ___CFXNotificationPost_block_invoke + 54
    17  CoreFoundation                      0x00694863 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1795
    18  CoreFoundation                      0x00527a07 _CFXNotificationPost + 599
    19  Foundation                          0x044271b7 -[NSNotificationCenter postNotification:] + 131
    20  testapp                           0x000f1263 -[AppDelegate(BranchSdk) application:openURL:sourceApplication:annotation:] + 531
    21  testapp                           0x000e921f -[AppDelegate(FacebookConnectPlugin) swizzled_application:openURL:sourceApplication:annotation:] + 335
    22  UIKit                               0x00a24b55 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 1160
    23  UIKit                               0x00a2446f -[UIApplication _applicationOpenURL:payload:] + 787
    24  UIKit                               0x00a35633 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 5408
    25  UIKit                               0x00a3b92f __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 238
    26  UIKit                               0x00a3b7d9 -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 469
    27  UIKit                               0x00a16067 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 197
    28  UIKit                               0x00a15c57 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 770
    29  FrontBoardServices                  0x05597177 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_2 + 71
    30  FrontBoardServices                  0x05596aae __40-[FBSSceneImpl _performDelegateCallOut:]_block_invoke + 54
    31  FrontBoardServices                  0x055ba27f __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 23
    32  FrontBoardServices                  0x055ba0ab -[FBSSerialQueue _performNext] + 174
    33  FrontBoardServices                  0x055ba4fa -[FBSSerialQueue _performNextFromRunLoopSource] + 52
    34  FrontBoardServices                  0x055b97e8 FBSSerialQueueRunLoopSourceHandler + 33
    35  CoreFoundation                      0x00592e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    36  CoreFoundation                      0x00588aeb __CFRunLoopDoSources0 + 523
    37  CoreFoundation                      0x00587f08 __CFRunLoopRun + 1032
    38  CoreFoundation                      0x00587846 CFRunLoopRunSpecific + 470
    39  CoreFoundation                      0x0058765b CFRunLoopRunInMode + 123
    40  GraphicsServices                    0x06136664 GSEventRunModal + 192
    41  GraphicsServices                    0x061364a1 GSEventRun + 104
    42  UIKit                               0x00a18eb9 UIApplicationMain + 160
    43  testapp                           0x0008a289 main + 89
    44  libdyld.dylib                       0x050c6a25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
@barocsi
Copy link
Author

barocsi commented Apr 25, 2016

As a workaround I have killed this one and recompiled the project.
absoluteString is not defined.
Please fix this.

 (void)postUnhandledURL:(NSNotification *)notification {
    // We create a JSON string result, because we're unable to handle the url. We will include the url in the return string.

   return;
    NSError *error;
    NSString *urlString;

    if ([notification.object respondsToSelector:@selector(absoluteString:)]) {
        urlString = [notification.object absoluteString];
    } else {
        urlString = notification.object;
    }

    NSDictionary *returnDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Unable to process URL", @"error", urlString, @"url", nil];
    NSData* returnJSON = [NSJSONSerialization dataWithJSONObject:returnDict
                                                         options:NSJSONWritingPrettyPrinted
                                                           error:&error];

    NSString *resultString = [[NSString alloc] initWithData:returnJSON encoding:NSUTF8StringEncoding];
    NSLog(@"Sending to DeepLinkHandler: %@", resultString);
    [self.commandDelegate evalJs:[NSString stringWithFormat:@"NonBranchLinkHandler(%@)", resultString]];

@jstoup111
Copy link

I've been noticing a large increase of crashes as well. Specifically when calling listOnSpotlight() it happens pretty frequently. Might be the same issue.

@aaustin
Copy link
Contributor

aaustin commented Apr 26, 2016

@jstoup111 Do you have the crash logs? This reported crash would be unrelated to listOnSpotlight.

@aaustin
Copy link
Contributor

aaustin commented Apr 26, 2016

I included a fix for the unhandler code in this PR. #120 Waiting for some testing to be done by our contractor team.

@jstoup111
Copy link

start registerView
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: encoded dictionary : {"$canonical_identifier":"user_7","$og_description":"Biking>All","$og_image_url":"http://cdn.website.com/image.png","$og_title":"Ivan","$exp_date":0,"$publicly_indexable":1,"url":"myapp://users/7"}
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: encoded dictionary : {"is_simulator":0,"app_version":"1.1.0","device_fingerprint_id":"242322019083953376","os":"iOS","identity_id":"242322019205549889","sdk":"ios0.11.17","debug":1,"data":{"$canonical_identifier":"user_7","$og_description":"Biking>All","$og_image_url":"http://cdn.website.com/image.png","$og_title":"Ivan","$exp_date":0,"$publicly_indexable":1,"url":"myapp://users/7"},"device_name":"iPhone","retryNumber":0,"ad_tracking_enabled":1,"session_id":"253544542752202486","os_version":"9.3.1","model":"iPhone7,2","branch_key":"mykey"}
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: [BNCServerInterface.m:182] using url = https://api.branch.io/v1/register-view
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: [BNCServerInterface.m:183] body = {
        "ad_tracking_enabled" = 1;
        "app_version" = "1.1.0";
        "branch_key" = "mykey";
        data =     {
            "$canonical_identifier" = "user_7";
            "$exp_date" = 0;
            "$og_description" = "Biking>All";
            "$og_image_url" = "http://cdn.website.com/image.png"
            "$og_title" = Ivan;
            "$publicly_indexable" = 1;
            url = "myapp://users/7";
        };
        debug = 1;
        "device_fingerprint_id" = 242322019083953376;
        "device_name" = iPhone;
        "identity_id" = 242322019205549889;
        "is_simulator" = 0;
        model = "iPhone7,2";
        os = iOS;
        "os_version" = "9.3.1";
        retryNumber = 0;
        sdk = "ios0.11.17";
        "session_id" = 253544542752202486;
    }
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: THREAD WARNING: ['BranchSDK'] took '12.109131' ms. Plugin should use a background thread.
Apr 26 10:27:00 iPhone MyApp[480] <Warning>: start listOnSpotlight
Apr 26 10:27:00 iPhone MyApp[480] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
    *** First throw call stack:
    (0x181ecae38 0x18152ff80 0x181daaebc 0x1000f0e08 0x1000ff774 0x1000ff488 0x182892628 0x181e8181c 0x181e814c0 0x181e7ebd4 0x181da8d10 0x183690088 0x18707df70 0x1000a9198 0x1819468b8)
Apr 26 10:27:00 iPhone SpringBoard[58] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Apr 26 10:27:00 iPhone SpringBoard[58] <Warning>: UNNotificationRegistrarConnectionListener connection invalidated
Apr 26 10:27:00 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.app.myapp[0xc11e][480]) <Notice>: Service exited due to signal: Abort trap: 6
Apr 26 10:27:00 iPhone SpringBoard[58] <Warning>: Application 'UIKitApplication:com.app.myapp[0xc11e]' crashed.
Apr 26 10:27:00 iPhone UserEventAgent[26] <Warning>: 494284245040: id=com.app.myapp pid=480, state=0
Apr 26 10:27:00 iPhone searchd[162] <Warning>: ====^^^^ DuetExpert missing data, count -> people:8 applicationDeepLinks:0 applications:8 requests:26 missingAllDataRequests:1
Apr 26 10:27:01 iPhone diagnosticd[82] <Error>: unable to find offset 0x8193d7ec in shared cache for arch 'arm64'
Apr 26 10:27:01 iPhone diagnosticd[82] <Error>: unable to find offset 0x81b3dda8 in shared cache for arch 'arm64'
Apr 26 10:27:01 iPhone diagnosticd[82] <Error>: Invalid offset 2176048552 into shared cache for arch 'arm64'
Apr 26 10:27:01 iPhone ReportCrash[481] <Notice>: platform_thread_get_unique_id matched 174100
Apr 26 10:27:01 iPhone ReportCrash[481] <Notice>: Formulating report for corpse[480] MyApp
Apr 26 10:27:01 iPhone ReportCrash[481] <Warning>: Saved type '109(109_MyApp)' report (3 of max 25) at /var/mobile/Library/Logs/CrashReporter/MyApp-2016-04-26-102701.ips.beta

My code that is executed

(function() {
    'use strict';

    angular.module('myapp.features.branch', [
            'myapp.core'
        ])
        .factory('BranchFactory', BranchFactory);

    function BranchFactory($ionicPlatform) {
        var universalObject;

        function createObj(id, title, description, image, isPrivate, meta) {
            return Branch.createBranchUniversalObject({
                canonicalIdentifier: id,
                title:               title,
                contentDescription:  description,
                contentImageUrl:     image,
                contentIndexingMode: isPrivate ? 'private' : 'public',
                contentMetadata:     meta
            }).then(function(obj) {
                universalObject = obj;
            }, function(err) {
                console.error(err);
            });
        }

        function registerView() {
            if(universalObject) {
                $ionicPlatform.ready(function() {
                    universalObject.registerView();
                    universalObject.listOnSpotlight();
                });
            }
        }

        function createLink(feature, channel) {
            return universalObject.generateShortUrl({
                feature: feature,
                channel: channel
            }, {});
        }

        function share(feature, channel) {
            return universalObject.showShareSheet({
                feature: feature,
                channel: channel
            }, {});
        }

        return {
            createObj:    createObj,
            registerView: registerView,
            createLink:   createLink,
            share:        share
        };
    }
})();

Implementation

BranchFactory.createObj('user_' + user.id,
                user.name,
                user.description,
                user.profile_image_url,
                false, {
                    'url':             'myapp://users/' + user.id,
                    '$og_title':       user.name,
                    '$og_description': user.description,
                    '$og_image_url':   user.profile_image_url
                }).then(function() {
                BranchFactory.registerView();
            });

@aaustin
Copy link
Contributor

aaustin commented Apr 27, 2016

Hey @jstoup111 - I got yours. It seems that the list on spotlight method is not functional... Added fix to my big PR with the fix for above. 45509cb

@aaustin
Copy link
Contributor

aaustin commented Apr 27, 2016

Both of these should be resolved now.

@aaustin aaustin closed this as completed Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants