[TIMOB-2317] Contact Picker crashes when selecting an email
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | Medium | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2011-06-23T14:57:23.000+0000 | 
| Affected Version/s | Release 1.6.0 | 
| Fix Version/s | Sprint 2011-25, Release 1.7.2 | 
| Components | iOS | 
| Labels | address, contacts, crash, defect, email, ios, rplist | 
| Reporter | dcpedit | 
| Assignee | Stephen Tramer | 
| Created | 2011-04-15T03:16:32.000+0000 | 
| Updated | 2011-07-08T17:10:58.000+0000 | 
Description
Using the following code:
  Ti.Contacts.showContacts({
    fields: ['email'],
    selectedProperty: function(e) {
      Ti.API.info('property selected');
    }
  });
This will crash the Contacts Picker if an email is selected when using a physical iphone. I think it has something to do with the fact that that the email labels are all "email" versus on the simulator, they are "home", "work", and "other". Here is the error that appears in the debugger at the time of the crash:
[ERROR] The application has crashed with an unhandled exception. Stack trace:
0   CoreFoundation                      0x30897ec1 __exceptionPreprocess + 96
1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
2   CoreFoundation                      0x308290bd -[__NSArrayI objectAtIndex:] + 160
3   Scratcher                           0x00067567 -[ContactsModule peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] + 354
4   AddressBookUI                       0x338a8d97 -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 158
5   AddressBookUI                       0x338b1b35 -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 228
6   AddressBookUI                       0x338c06ab -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 46
7   AddressBookUI                       0x338bf101 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 360
8   UIKit                               0x31f7ae6f -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662
9   UIKit                               0x31f772af -[UITableView _userSelectRowAtIndexPath:] + 130
10  Foundation                          0x349c7e8d __NSFireDelayedPerform + 368
11  CoreFoundation                      0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
12  CoreFoundation                      0x3084e2ad __CFRunLoopDoTimer + 860
13  CoreFoundation                      0x3081f7a5 __CFRunLoopRun + 1088
14  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
15  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
16  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
17  GraphicsServices                    0x31e4469f GSEventRun + 62
18  UIKit                               0x31e51123 -[UIApplication _run] + 402
19  UIKit                               0x31e4f12f UIApplicationMain + 670
20  Scratcher                           0x00003c8b main + 42
21  Scratcher                           0x0000384c start + 40
2010-11-09 18:34:47.455 Scratcher[383:307] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x30897ed3 __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
    2   CoreFoundation                      0x308290bd -[__NSArrayI objectAtIndex:] + 160
    3   Scratcher                           0x00067567 -[ContactsModule peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] + 354
    4   AddressBookUI                       0x338a8d97 -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 158
    5   AddressBookUI                       0x338b1b35 -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 228
    6   AddressBookUI                       0x338c06ab -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 46
    7   AddressBookUI                       0x338bf101 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 360
    8   UIKit                               0x31f7ae6f -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662
    9   UIKit                               0x31f772af -[UITableView _userSelectRowAtIndexPath:] + 130
    10  Foundation                          0x349c7e8d __NSFireDelayedPerform + 368
    11  CoreFoundation                      0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
    12  CoreFoundation                      0x3084e2ad __CFRunLoopDoTimer + 860
    13  CoreFoundation                      0x3081f7a5 __CFRunLoopRun + 1088
    14  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
    15  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
    16  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
    17  GraphicsServices                    0x31e4469f GSEventRun + 62
    18  UIKit                               0x31e51123 -[UIApplication _run] + 402
    19  UIKit                               0x31e4f12f UIApplicationMain + 670
    20  Scratcher                           0x00003c8b main + 42
    21  Scratcher                           0x0000384c start + 40
)
terminate called after throwing an instance of 'NSException'
I also tried using the selectedPerson callback:
  Ti.Contacts.showContacts({
    selectedPerson: function(e) { 
      var person = e.person;
      var emails = person.email;
    }
  });
But that crashed as well with a different error:
[ERROR] The application has crashed with an unhandled exception. Stack trace:
0   CoreFoundation                      0x30897ec1 __exceptionPreprocess + 96
1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
2   CoreFoundation                      0x30897d15 +[NSException raise:format:arguments:] + 68
3   CoreFoundation                      0x30897d4f +[NSException raise:format:] + 34
4   CoreFoundation                      0x3081bbd5 -[__NSCFDictionary setObject:forKey:] + 244
5   Foundation                          0x349b9b91 -[NSMutableDictionary(NSKeyValueCoding) setValue:forKey:] + 16
6   Scratcher                           0x00056035 -[TiContactsPerson dictionaryFromMultiValue:] + 208
7   Scratcher                           0x00056b33 -[TiContactsPerson valueForUndefinedKey:] + 298
8   CoreFoundation                      0x308362eb -[NSObject(NSObject) performSelector:withObject:] + 22
9   Foundation                          0x349c7825 __NSThreadPerformPerform + 268
10  CoreFoundation                      0x3084df25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
11  CoreFoundation                      0x3081fba7 __CFRunLoopDoSources0 + 382
12  CoreFoundation                      0x3081f44b __CFRunLoopRun + 230
13  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
14  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
15  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
16  GraphicsServices                    0x31e4469f GSEventRun + 62
17  UIKit                               0x31e51123 -[UIApplication _run] + 402
18  UIKit                               0x31e4f12f UIApplicationMain + 670
19  Scratcher                           0x00003bb7 main + 42
20  Scratcher                           0x00003778 start + 40
2010-11-09 20:21:26.424 Scratcher[828:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil key'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x30897ed3 __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
    2   CoreFoundation                      0x30897d15 +[NSException raise:format:arguments:] + 68
    3   CoreFoundation                      0x30897d4f +[NSException raise:format:] + 34
    4   CoreFoundation                      0x3081bbd5 -[__NSCFDictionary setObject:forKey:] + 244
    5   Foundation                          0x349b9b91 -[NSMutableDictionary(NSKeyValueCoding) setValue:forKey:] + 16
    6   Scratcher                           0x00056035 -[TiContactsPerson dictionaryFromMultiValue:] + 208
    7   Scratcher                           0x00056b33 -[TiContactsPerson valueForUndefinedKey:] + 298
    8   CoreFoundation                      0x308362eb -[NSObject(NSObject) performSelector:withObject:] + 22
    9   Foundation                          0x349c7825 __NSThreadPerformPerform + 268
    10  CoreFoundation                      0x3084df25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
    11  CoreFoundation                      0x3081fba7 __CFRunLoopDoSources0 + 382
    12  CoreFoundation                      0x3081f44b __CFRunLoopRun + 230
    13  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
    14  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
    15  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
    16  GraphicsServices                    0x31e4469f GSEventRun + 62
    17  UIKit                               0x31e51123 -[UIApplication _run] + 402
    18  UIKit                               0x31e4f12f UIApplicationMain + 670
    19  Scratcher                           0x00003bb7 main + 42
    20  Scratcher                           0x00003778 start + 40
)
terminate called after throwing an instance of 'NSException'
Attachments
| File | Date | Size | 
|---|---|---|
| gmailContactsCrashLog.log | 2011-06-08T08:02:30.000+0000 | 9999 | 
This is probably not the "correct" fix, but I was able to prevent it from crashing and return the correct email address with the following change:
ContactsModule.m line 378
Hi,
I have exactly the same problem. As you said, this comes from the 'email' label.
I think this is when you synchronise your contacts with other systems like google for instance. All my contacts have 'email' labels instead of 'home', 'work' or 'other'.
The ones that are directly created on the iPhone work well.
One question: I would like to use your workaround but what is CFlabel ?
Thanks !
Sorry, I understood after that you modified directly the ContactModule class file.
This still does not work for me.
What's the process then ? I compiled directly in xcode with Device and Release. But then the only new directory was Release-iphonesimulator. I then took the app from this directly to load on my device. Is that the correct way to proceed ?
Would be great if a fix was directly integrated in Titanium for next release.
I am still trying to find a solution for this issue.
I feel that the problem is similar to this one (#1342), which has been resolved in 1.5. The difference is that instead of having custom labels, we have a kind of default label 'email'.
Any clue on how to fix that ? I did not manage to fix it with the solution provided.
OK, this has been reported often enough that I can't dismiss it as user error any more. Also, there's sample code now.
We are having the same issue with address. It seems that any contact created from the iOS Maps App does not set the label on address. To test, using the following code on device. Click 'Test Contacts' and see if it crashes. If it does, look in the console to see what the last contact was. If it doesn't, do a maps search for any business, add as a contact, and then run again. Built with 1.6 running on 4.2, this consistently crashed the app. Then, change the new contacts address to 'other' and try again.
Ticket Reference: http://developer.appcelerator.com/helpdesk/view/76124">http://developer.appcelerator.com/helpdesk/view/76124
This issue needs to be resolved for us to release our app.
We are still working on some other items to make the app ready but we need to know this is going to get some attention soon.
Is there a plan or is this scheduled as a priority?
(from [42a8c3893133671e0d98d55ab556ff24966d888f]) [#2317 state:fixed-in-qa milestone:"Sprint-2011-11"][#1849 state:fixed-in-qa milestone:Sprint-2011-11][#1958 state:fixed-in-qa milestone:Sprint-2011-11] Numerous fixes for crashers in Contacts. https://github.com/appcelerator/titanium_mobile/commit/42a8c3893133671e0d98d55ab556ff24966d888f"> https://github.com/appcelerator/titanium_mobile/commit/42a8c3893133...
Awesome - glad to see this has a resolution path!
How can I relate milestones to builds available via the continuous builds page to know if a particular build includes the fix?
Tested with Titanium SDK version: 1.7.0 (03/18/11 12:00 19be393) on
Simulator 4.0
iPad2 4.3
This bug is still not fixed... Here is a link to the youtube video, I don't really have any way to prove it other then a video. http://www.youtube.com/watch?v=xL2CX-UbX00
Regression
Test code
var win = Ti.UI.createWindow(); var values = { selectedProperty: function(e){ alert(e.value); } }; var button = Ti.UI.createButton({ title: 'Open', height: 60, width: 200 }); button.addEventListener('click', function(e){ Ti.Contacts.showContacts(values); }); win.add(button); win.open();Tested on
iPhone4 4.3.1, TiSDK 1.7.0 (May 3 2011 15:12 r05b7ea37)we're still seeing this issue on 1.6.2 when accessing multi-value fields: GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".Setting environment variable "KR_ORIG_DYLD_LIBRARY_PATH" to null value. Setting environment variable "KR_ORIG_DYLD_FRAMEWORK_PATH" to null value. Attaching to process 1202.
can we raise the priority to a reasonable level?
Finally put this to bed. Technically an Apple bug, but they'd never fix it.
closing against verizon iphone4 (4.2.8) and iphone3 (3.1.3) [INFO] Titanium SDK version: 1.7.0 (05/24/11 00:41 3982f4e...)
This still seems to be happening with contacts synced with gmail. I've attached "gmailContactsCrashLog.log".
Additional Notes from Customer
Gmail assigns them the label of 'email' and this crashes the app. However when you manually assign a contact a new email address and give it the custom field of 'email' it works. This makes me think that gmail is adding in additional blank fields or such not just 'email'.Finally closing this bug for good will involve testing every single possible email/contacts configuration available on iOS. Will need QA's assistance to resolve.
Time includes budgeting for some, but not all, testing. We're going to have to be very rigorous.
Could not reproduce with Jon Alter's test code above. Will try additional scenarios to best ensure the fix.
Tested with iPad 2 4.3.3 with 1.7.2.v20110706211037 with Exchange mail and device contact, did not encounter the crash
Verified the following: exchange account listings, gmail account contact listings with multi-value-fields, local contacts with multi-value fields including custom and default. Verified on iPhone 4, 4.3.3, iPad 2 4.3.3, iPhone 3G 3.1.3.