Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3309] iOS: Facebook Graph Method Crashes in some circumstances

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-05-18T09:16:39.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.7.0, Sprint 2011-16
ComponentsiOS
Labelsdefect, ios, klist, release-1.7.0, reported-1.7.0, rplist
ReporterRick Blalock
AssigneeStephen Tramer
Created2011-04-15T03:41:51.000+0000
Updated2011-05-18T09:16:39.000+0000

Description

I've noticed several people trying to use certain properties that will crash the app. One such example:

HD Ticket here: http://developer.appcelerator.com/helpdesk/view/76207">http://developer.appcelerator.com/helpdesk/view/76207

Will crash the app:

  var data = {
        link: "https://developer.mozilla.org/en/JavaScript",
        name: "Best online Javascript reference",
        message: "Use Mozilla's online Javascript reference",
        caption: "MDN Javascript Reference",
        picture: "https://developer.mozilla.org/media/img/mdn-logo.png",
        description: "This section of the site is dedicated to JavaScript-the-language, the parts that are not specific to web pages or other host environments...",
        test: [ {foo: 'some test'} ]
    };
    Titanium.Facebook.requestWithGraphPath('me/feed', data, 'POST', function(e) {//...});

Exception thrown: http://pastie.org/1651703">http://pastie.org/1651703

Will crash the app with no exception:

  var data = {
        link: "https://developer.mozilla.org/en/JavaScript",
        name: "Best online Javascript reference",
        message: "Use Mozilla's online Javascript reference",
        caption: "MDN Javascript Reference",
        picture: "https://developer.mozilla.org/media/img/mdn-logo.png",
        description: "This section of the site is dedicated to JavaScript-the-language, the parts that are not specific to web pages or other host environments...",
        test: ['test']
    };
    Titanium.Facebook.requestWithGraphPath('me/feed', data, 'POST', function(e) {//...});

Will not crash the app:

  var data = {
        link: "https://developer.mozilla.org/en/JavaScript",
        name: "Best online Javascript reference",
        message: "Use Mozilla's online Javascript reference",
        caption: "MDN Javascript Reference",
        picture: "https://developer.mozilla.org/media/img/mdn-logo.png",
        description: "This section of the site is dedicated to JavaScript-the-language, the parts that are not specific to web pages or other host environments...",
        test: 'test'
    };
    Titanium.Facebook.requestWithGraphPath('me/feed', data, 'POST', function(e) {//...});

Even though 'test' property is irrelevant to the graph API, this should still not throw an exception from our side of things. Facebook does have a few properties that require an object literal / dictionary.

Comments

  1. Rick Blalock 2011-04-15

    A more relavent test is the following, since the privacy api's expect this type of object:

             var data = {
                   privacy: { value: 'CUSTOM', friends: 'SELF' },
                   name: "Review this: Best online Javascript reference",
                   message: "Use Mozilla's online Javascript reference"
               };
               
               Ti.Facebook.requestWithGraphPath('me/feed', data, 'POST', function(e) {// ...});
       

    Stack trace here: http://pastie.org/1723291">http://pastie.org/1723291

    If a property is an object literal / dictionary it will throw the above exception. If it's an array, it will simply crash with no exception given.

  2. Rick Blalock 2011-04-15

    The workaround for the above is as follows:

             var data = {
                   privacy: '{ value: "CUSTOM", friends: "SELF" }',
                   name: "Review this: Best online Javascript reference",
                   message: "Use Mozilla's online Javascript reference"
               };
       

    This will work fine as long as the object literal is actually a string.

  3. Dawson Toth 2011-04-15

    klist'd, fixed reported-1.7.0 tag, set milestone to tbs

  4. Dawson Toth 2011-04-15

    and assigned to Reggie

  5. Stephen Tramer 2011-04-18

    Fixed by commit fb31bd (https://github.com/appcelerator/titanium_mobile/commit/fb31bde75a145f4905393633e313226ba7729d33)
  6. Eric Merriman 2011-05-18

    Neither of the two provided code samples crash iOS (iPhone 4, 4.3.3) or the simulator with 1.7.0RC1. Associated tests in KS also do not crash. Closing.

JSON Source