Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(ios9) HangTracer interval is 0, forcing to 1s, while using Contact Framework

I was working with Contact Framework (just adding a contact). And It was saved without any problem (I double checked in Contact List) but recently I notice that this message appears on console:

2015-06-12 09:57:39.723 AddingContactToAddressBook[819:291346] HangTracer interval is 0, forcing to 1s

2015-06-12 09:57:39.725 AddingContactToAddressBook[819:291346] made new hangtracer connection:0x332e10

I googled it and I only found a mention in Twitter, about “What new wizardry is this?”.

Actually, I don’t know if my code is the cause of this problem.

 -(void)verifyUserAuthorizationInIOS9andLower{

CNContactStore * contactStore = [[CNContactStore alloc]init];

if ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusNotDetermined) {
    [contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * __nullable error) {
        
        if (granted==YES) {
            [self addContactInIOS9andLower];
            
            if ([self addContactInIOS9andLower]) {
                NSLog(@"Error");
            }
            
            else{
                NSLog(@"Error");
            }
        }
        
        else{
            NSLog(@"Error");
        }
                                                
    }];

}

else if ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusAuthorized){
    [self addContactInIOS9andLower];
}
else {
    NSLog(@"Error");
}
}


-(BOOL)addContactInIOS9andLower{

CNContactStore * contactStore = [[CNContactStore alloc]init];

CNMutableContact *mutableContact = [[CNMutableContact alloc]init];

mutableContact.givenName = name;
mutableContact.familyName = lastname;

mutableContact.phoneNumbers = [[NSArray alloc]initWithObjects:[CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberiPhone value:[CNPhoneNumber phoneNumberWithStringValue:phone]], nil];

CNSaveRequest * saveRequest = [[CNSaveRequest alloc]init];
[saveRequest addContact:mutableContact toContainerWithIdentifier:nil];

NSError *error = nil;

if ([contactStore executeSaveRequest:saveRequest error:&error]){
    return NO;
}

else{
    return YES;
}
}
like image 777
Jadekin Avatar asked Jun 12 '15 15:06

Jadekin


1 Answers

Debugging with a breakpoint on NSLog gives a call to [UIApplication startHangtracer:]. This occurs in the thread under HTStartHangTracing.

Th fact that it occurs since iOS 9, and that it is from within UIApplication, gives me a strong feeling towards Apple's new bug reporting framework in iOS 9.

This might just be the part about detecting when an application hangs.

Someone should investigate their app bugreports when distributed through TestFlight, to confirm that this HangTracer is part of that.

like image 116
vrwim Avatar answered Oct 20 '22 08:10

vrwim