Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2317] Contact Picker crashes when selecting an email

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-06-23T14:57:23.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sSprint 2011-25, Release 1.7.2
ComponentsiOS
Labelsaddress, contacts, crash, defect, email, ios, rplist
Reporterdcpedit
AssigneeStephen Tramer
Created2011-04-15T03:16:32.000+0000
Updated2011-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

FileDateSize
gmailContactsCrashLog.log2011-06-08T08:02:30.000+00009999

Comments

  1. dcpedit 2011-04-15

    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

       
             if (CFlabel) {
               label = [NSString stringWithString:[[[TiContactsPerson multiValueLabels] allKeysForObject:(NSString*)CFlabel] objectAtIndex:0]];
               CFRelease(CFlabel);
             }
             else {
               label = @"none";
             }
       
  2. Guillaume 2011-04-15

    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 !

  3. Guillaume 2011-04-15

    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.

  4. Guillaume 2011-04-15

    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.

  5. Stephen Tramer 2011-04-15

    OK, this has been reported often enough that I can't dismiss it as user error any more. Also, there's sample code now.

  6. Alan Leard 2011-04-15

    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.

       var win = Titanium.UI.createWindow();
       var button = Ti.UI.createButton({
       width:150,
       height:50,
       title:'Test Contacts'
       });
       win.add(button);
       button.addEventListener('click', function(){
       var people = Titanium.Contacts.getAllPeople();
           for (var i = 0, all = people.length; i < all; i++) 
           {
               Ti.API.info('Working on contact '+i+', '+people[i].fullName);
               for (var label in people[i].email) {
                   var addrs = people[i].email[label];
               Ti.API.info("Email: "+people[i].email[label]);
               }
               for (var label in people[i].address) {
                   var addrs = people[i].address[label];
                   for (var ii = 0; ii < addrs.length; ii++) 
                   {
                       if (addrs[ii].Street != undefined && addrs[ii].Street.length > 1)
                       {
                           Ti.API.info("  address["+label+"]: "+addrs[ii].Street);
                       }
                   }
               }
           }
           alert('Contacts Successfully Tested');
       });
       win.open();
       

    Ticket Reference: http://developer.appcelerator.com/helpdesk/view/76124">http://developer.appcelerator.com/helpdesk/view/76124

  7. johnvpataki 2011-04-15

    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?

  8. Jeff Haynie 2011-04-15

    (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...

  9. johnvpataki 2011-04-15

    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?

  10. Natalie Huynh 2011-04-15

    Tested with Titanium SDK version: 1.7.0 (03/18/11 12:00 19be393) on
    Simulator 4.0
    iPad2 4.3

  11. John Hass 2011-05-03

    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
  12. Jon Alter 2011-05-03

    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)
  13. tom quas 2011-05-10

    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. [INFO] get all contacts [INFO] find all() [INFO] getAllPeople() [INFO] reloaded contacts [INFO] 20 contacts via all [INFO] found all() [INFO] total contacts: 20 [DEBUG] fire app event: sync.progress.init with { max = 20; stage = 0; } [INFO] [object TiContactsPerson] [ERROR] The application has crashed with an unhandled exception. Stack trace: 0 CoreFoundation 0x0238358c __exceptionPreprocess + 156 1 libobjc.A.dylib 0x024d7313 objc_exception_throw + 44 2 CoreFoundation 0x0233bef8 +[NSException raise:format:arguments:] + 136 3 CoreFoundation 0x0233be6a +[NSException raise:format:] + 58 4 CoreFoundation 0x02381e15 -[__NSCFDictionary setObject:forKey:] + 293 5 app 0x000b50d0 -[TiContactsPerson valueForUndefinedKey:] + 928 6 Foundation 0x0066c94e __NSThreadPerformPerform + 251 7 CoreFoundation 0x023648ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 8 CoreFoundation 0x022c288b __CFRunLoopDoSources0 + 571 9 CoreFoundation 0x022c1d86 __CFRunLoopRun + 470 10 CoreFoundation 0x022c1840 CFRunLoopRunSpecific + 208 11 CoreFoundation 0x022c1761 CFRunLoopRunInMode + 97 12 GraphicsServices 0x041891c4 GSEventRunModal + 217 13 GraphicsServices 0x04189289 GSEventRun + 115 14 UIKit 0x008fbc93 UIApplicationMain + 1160 15 app 0x00003d9e main + 104 16 app 0x00002cc5 start + 53 2011-05-10 14:42:44.770 app[1202:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: id)' *** Call stack at first throw: ( 0 CoreFoundation 0x023835a9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x024d7313 objc_exception_throw + 44 2 CoreFoundation 0x0233bef8 +[NSException raise:format:arguments:] + 136 3 CoreFoundation 0x0233be6a +[NSException raise:format:] + 58 4 CoreFoundation 0x02381e15 -[__NSCFDictionary setObject:forKey:] + 293 5 app 0x000b50d0 -[TiContactsPerson valueForUndefinedKey:] + 928 6 Foundation 0x0066c94e __NSThreadPerformPerform + 251 7 CoreFoundation 0x023648ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 8 CoreFoundation 0x022c288b __CFRunLoopDoSources0 + 571 9 CoreFoundation 0x022c1d86 __CFRunLoopRun + 470 10 CoreFoundation 0x022c1840 CFRunLoopRunSpecific + 208 11 CoreFoundation 0x022c1761 CFRunLoopRunInMode + 97 12 GraphicsServices 0x041891c4 GSEventRunModal + 217 13 GraphicsServices 0x04189289 GSEventRun + 115 14 UIKit 0x008fbc93 UIApplicationMain + 1160 15 app 0x00003d9e main + 104 16 app 0x00002cc5 start + 53 ) terminate called after throwing an instance of 'NSException' sharedlibrary apply-load-rules all Current language: auto; currently objective-c
  14. tom quas 2011-05-10

    can we raise the priority to a reasonable level?
  15. Stephen Tramer 2011-05-17

    Finally put this to bed. Technically an Apple bug, but they'd never fix it.
  16. Thomas Huelbert 2011-05-24

    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...)
  17. Dawson Toth 2011-06-08

    This still seems to be happening with contacts synced with gmail. I've attached "gmailContactsCrashLog.log".
  18. Dawson Toth 2011-06-09

    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'.
  19. Stephen Tramer 2011-06-21

    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.
  20. Stephen Tramer 2011-06-21

    Time includes budgeting for some, but not all, testing. We're going to have to be very rigorous.
  21. Eric Merriman 2011-07-07

    Could not reproduce with Jon Alter's test code above. Will try additional scenarios to best ensure the fix.
  22. Natalie Huynh 2011-07-08

    Tested with iPad 2 4.3.3 with 1.7.2.v20110706211037 with Exchange mail and device contact, did not encounter the crash
  23. Eric Merriman 2011-07-08

    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.

JSON Source