Skip to main content
fengd9946600
Inspiring
October 30, 2017
Question

Code crash when running on iOS 11

  • October 30, 2017
  • 2 replies
  • 446 views

Hi there,

The following codes run well on iOS 10 for my Facebook ANE, but crash when I upgrade my iPad to iOS 11. The Air sdk is version 26.

  NSString *callback = (argc >0 && argv[0] !=NULL ? FPANE_FREObjectToNSString(argv[0]) : NULL);

  NSString *handle = (callback == NULL ? @"BASIC_USER_PROFILE" : [@"BASIC_USER_PROFILE-" stringByAppendingString:callback]);

  [xfFB dispatchEvent:logging withMessage:[@"[requestBasicUserProfile] [callback:" stringByAppendingFormat:@" %@]",callback]];

  FBSDKProfile* profile = [FBSDKProfile currentProfile];

  FREObject result = NULL;

  FREObject basicProfileResult = NULL;

  FREResult classCallResult;

  FREObject excep = NULL;

  if (profile != NULL) {

  classCallResult = FRENewObject((const uint8_t*)"com.xflying.ane.xffb.data.BasicUserProfile",0,NULL,&result, excep);

  if (classCallResult == FRE_OK) {

  [xfFB dispatchEvent:logging withMessage:@"Basic Profile init ok"];

  FRESetObjectProperty(result, (const uint8_t*)"firstName",

   FPANE_NSStringToFREObject(profile.firstName),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"lastName",

   FPANE_NSStringToFREObject(profile.lastName),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"linkURI",

   FPANE_NSStringToFREObject([profile.linkURL absoluteString]),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"middleName",

   FPANE_NSStringToFREObject(profile.middleName),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"name",

   FPANE_NSStringToFREObject(profile.name),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"refreshDate",

   FPANE_doubleToFREObject([profile.refreshDate timeIntervalSince1970]),

   NULL);

  FRESetObjectProperty(result, (const uint8_t*)"userID",

   FPANE_NSStringToFREObject(profile.userID),

   NULL);

  classCallResult = FRECallObjectMethod(result, (const uint8_t *)"toJson", 0, NULL,

    &basicProfileResult, NULL);

  }

  if (classCallResult == FRE_OK) {

       [xfFB dispatchEvent:handle withMessage:FPANE_FREObjectToNSString(basicProfileResult)];

  } else {

... ...

  }

  [xfFB dispatchEvent:@"BASIC_USER_PROFILE_ERROR" withMessage:[@"[requestBasicUserProfile] " stringByAppendingFormat:@"%@",error]];

  }

it crashes at line 44, but I am not sure is it because of the code (FRECallObjectMethod) at line 39 since the same function call FPANE_FREObjectToNSString at line 1 returns as expected.

The crashed function call FPANE_FREObjectToNSString is defined as below, so the actual crash point is at line 5 which calls FREGetObjectAsUTF8, the object is generated by FRECallObjectMethod.

NSString * FPANE_FREObjectToNSString(FREObject object)

{

    uint32_t stringLength;

    const uint8_t *string;

    FREGetObjectAsUTF8(object, &stringLength, &string);

    return [NSString stringWithUTF8String 😞char*)string];

}

Any crash case reported the same issue? Is it a bug?

Regards,

David

This topic has been closed for replies.

2 replies

fengd9946600
Inspiring
October 30, 2017

I found a Cocoa document mention about the memory management policy. It seems related things.

If I change the code to:

     error = [NSString stringWithFormat:@"%@%@", @"[requestBasicUserProfile] ",msg];

it works!

Does anyone know the pros or reason why of such a memory management?

fengd9946600
Inspiring
October 30, 2017

After many tries and errors, I found that the crash is nothing to do with the code I listed above but inside the else block inside line between 46-48 which did not show.

It still weird, actually the program didn't run into the block and inside the "else" block there are statements simply like

  NSString *msg = [[NSString init] alloc];

  msg = @"some msg";

  error = [@"[requestBasicUserProfile] " stringByAppendingFormat:@"%@",msg];

And the app run well if I remove the 3rd. statement. It looks like an iOS 11 bug.