{ "id": "62949", "key": "TIMOB-2317", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11357", "description": "Mobile 1.8.0 M04", "name": "Sprint 2011-25", "archived": true, "released": true, "releaseDate": "2011-06-27" }, { "id": "11570", "description": "", "name": "Release 1.7.2", "archived": true, "released": true, "releaseDate": "2011-07-21" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-06-23T14:57:23.000+0000", "created": "2011-04-15T03:16:32.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "address", "contacts", "crash", "defect", "email", "ios", "rplist" ], "versions": [ { "id": "11233", "name": "Release 1.6.0", "archived": true, "released": true, "releaseDate": "2011-02-23" } ], "issuelinks": [], "assignee": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-07-08T17:10:58.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
Using the following code:
\r\n\r\n Ti.Contacts.showContacts({\r\n fields: ['email'],\r\n selectedProperty: function(e) {\r\n Ti.API.info('property selected');\r\n }\r\n });
\r\n
\r\nThis will crash the Contacts Picker if an email is selected when\r\nusing a physical iphone. I think it has something to do with the\r\nfact that that the email labels are all \"email\" versus on the\r\nsimulator, they are \"home\", \"work\", and \"other\". Here is the error\r\nthat appears in the debugger at the time of the crash:
\r\n\r\n[ERROR] The application has crashed with an unhandled exception. Stack trace:\r\n\r\n0 CoreFoundation 0x30897ec1 __exceptionPreprocess + 96\r\n1 libobjc.A.dylib 0x3002f811 objc_exception_throw + 24\r\n2 CoreFoundation 0x308290bd -[__NSArrayI objectAtIndex:] + 160\r\n3 Scratcher 0x00067567 -[ContactsModule peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] + 354\r\n4 AddressBookUI 0x338a8d97 -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 158\r\n5 AddressBookUI 0x338b1b35 -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 228\r\n6 AddressBookUI 0x338c06ab -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 46\r\n7 AddressBookUI 0x338bf101 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 360\r\n8 UIKit 0x31f7ae6f -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662\r\n9 UIKit 0x31f772af -[UITableView _userSelectRowAtIndexPath:] + 130\r\n10 Foundation 0x349c7e8d __NSFireDelayedPerform + 368\r\n11 CoreFoundation 0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14\r\n12 CoreFoundation 0x3084e2ad __CFRunLoopDoTimer + 860\r\n13 CoreFoundation 0x3081f7a5 __CFRunLoopRun + 1088\r\n14 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230\r\n15 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58\r\n16 GraphicsServices 0x31e445f3 GSEventRunModal + 114\r\n17 GraphicsServices 0x31e4469f GSEventRun + 62\r\n18 UIKit 0x31e51123 -[UIApplication _run] + 402\r\n19 UIKit 0x31e4f12f UIApplicationMain + 670\r\n20 Scratcher 0x00003c8b main + 42\r\n21 Scratcher 0x0000384c start + 40\r\n\r\n\r\n2010-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'\r\n*** Call stack at first throw:\r\n(\r\n 0 CoreFoundation 0x30897ed3 __exceptionPreprocess + 114\r\n 1 libobjc.A.dylib 0x3002f811 objc_exception_throw + 24\r\n 2 CoreFoundation 0x308290bd -[__NSArrayI objectAtIndex:] + 160\r\n 3 Scratcher 0x00067567 -[ContactsModule peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] + 354\r\n 4 AddressBookUI 0x338a8d97 -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 158\r\n 5 AddressBookUI 0x338b1b35 -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 228\r\n 6 AddressBookUI 0x338c06ab -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 46\r\n 7 AddressBookUI 0x338bf101 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 360\r\n 8 UIKit 0x31f7ae6f -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662\r\n 9 UIKit 0x31f772af -[UITableView _userSelectRowAtIndexPath:] + 130\r\n 10 Foundation 0x349c7e8d __NSFireDelayedPerform + 368\r\n 11 CoreFoundation 0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14\r\n 12 CoreFoundation 0x3084e2ad __CFRunLoopDoTimer + 860\r\n 13 CoreFoundation 0x3081f7a5 __CFRunLoopRun + 1088\r\n 14 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230\r\n 15 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58\r\n 16 GraphicsServices 0x31e445f3 GSEventRunModal + 114\r\n 17 GraphicsServices 0x31e4469f GSEventRun + 62\r\n 18 UIKit 0x31e51123 -[UIApplication _run] + 402\r\n 19 UIKit 0x31e4f12f UIApplicationMain + 670\r\n 20 Scratcher 0x00003c8b main + 42\r\n 21 Scratcher 0x0000384c start + 40\r\n)\r\nterminate called after throwing an instance of 'NSException'
\r\n
\r\nI also tried using the selectedPerson callback:
\r\n\r\n Ti.Contacts.showContacts({\r\n selectedPerson: function(e) { \r\n var person = e.person;\r\n var emails = person.email;\r\n }\r\n });
\r\n
\r\nBut that crashed as well with a different error:
\r\n\r\n[ERROR] The application has crashed with an unhandled exception. Stack trace:\r\n\r\n0 CoreFoundation 0x30897ec1 __exceptionPreprocess + 96\r\n1 libobjc.A.dylib 0x3002f811 objc_exception_throw + 24\r\n2 CoreFoundation 0x30897d15 +[NSException raise:format:arguments:] + 68\r\n3 CoreFoundation 0x30897d4f +[NSException raise:format:] + 34\r\n4 CoreFoundation 0x3081bbd5 -[__NSCFDictionary setObject:forKey:] + 244\r\n5 Foundation 0x349b9b91 -[NSMutableDictionary(NSKeyValueCoding) setValue:forKey:] + 16\r\n6 Scratcher 0x00056035 -[TiContactsPerson dictionaryFromMultiValue:] + 208\r\n7 Scratcher 0x00056b33 -[TiContactsPerson valueForUndefinedKey:] + 298\r\n8 CoreFoundation 0x308362eb -[NSObject(NSObject) performSelector:withObject:] + 22\r\n9 Foundation 0x349c7825 __NSThreadPerformPerform + 268\r\n10 CoreFoundation 0x3084df25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12\r\n11 CoreFoundation 0x3081fba7 __CFRunLoopDoSources0 + 382\r\n12 CoreFoundation 0x3081f44b __CFRunLoopRun + 230\r\n13 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230\r\n14 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58\r\n15 GraphicsServices 0x31e445f3 GSEventRunModal + 114\r\n16 GraphicsServices 0x31e4469f GSEventRun + 62\r\n17 UIKit 0x31e51123 -[UIApplication _run] + 402\r\n18 UIKit 0x31e4f12f UIApplicationMain + 670\r\n19 Scratcher 0x00003bb7 main + 42\r\n20 Scratcher 0x00003778 start + 40\r\n\r\n\r\n2010-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'\r\n*** Call stack at first throw:\r\n(\r\n 0 CoreFoundation 0x30897ed3 __exceptionPreprocess + 114\r\n 1 libobjc.A.dylib 0x3002f811 objc_exception_throw + 24\r\n 2 CoreFoundation 0x30897d15 +[NSException raise:format:arguments:] + 68\r\n 3 CoreFoundation 0x30897d4f +[NSException raise:format:] + 34\r\n 4 CoreFoundation 0x3081bbd5 -[__NSCFDictionary setObject:forKey:] + 244\r\n 5 Foundation 0x349b9b91 -[NSMutableDictionary(NSKeyValueCoding) setValue:forKey:] + 16\r\n 6 Scratcher 0x00056035 -[TiContactsPerson dictionaryFromMultiValue:] + 208\r\n 7 Scratcher 0x00056b33 -[TiContactsPerson valueForUndefinedKey:] + 298\r\n 8 CoreFoundation 0x308362eb -[NSObject(NSObject) performSelector:withObject:] + 22\r\n 9 Foundation 0x349c7825 __NSThreadPerformPerform + 268\r\n 10 CoreFoundation 0x3084df25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12\r\n 11 CoreFoundation 0x3081fba7 __CFRunLoopDoSources0 + 382\r\n 12 CoreFoundation 0x3081f44b __CFRunLoopRun + 230\r\n 13 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230\r\n 14 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58\r\n 15 GraphicsServices 0x31e445f3 GSEventRunModal + 114\r\n 16 GraphicsServices 0x31e4469f GSEventRun + 62\r\n 17 UIKit 0x31e51123 -[UIApplication _run] + 402\r\n 18 UIKit 0x31e4f12f UIApplicationMain + 670\r\n 19 Scratcher 0x00003bb7 main + 42\r\n 20 Scratcher 0x00003778 start + 40\r\n)\r\nterminate called after throwing an instance of 'NSException'
\r\n
This is probably not the \"correct\" fix, but I was able to\nprevent it from crashing and return the correct email address with\nthe following change:
\nContactsModule.m line 378
\n\n if (CFlabel) {\n label = [NSString stringWithString:[[[TiContactsPerson multiValueLabels] allKeysForObject:(NSString*)CFlabel] objectAtIndex:0]];\n CFRelease(CFlabel);\n }\n else {\n label = @\"none\";\n }
\n
Hi,
\nI have exactly the same problem. As you said, this comes from the\n'email' label.
\nI think this is when you synchronise your contacts with other\nsystems like google for instance. All my contacts have 'email'\nlabels instead of 'home', 'work' or 'other'.
\nThe ones that are directly created on the iPhone work well.
One question: I would like to use your workaround but what is\nCFlabel ?
\nThanks !
Sorry, I understood after that you modified directly the\nContactModule class file.
\nThis still does not work for me.
\nWhat's the process then ? I compiled directly in xcode with Device\nand Release. But then the only new directory was\nRelease-iphonesimulator. I then took the app from this directly to\nload on my device. Is that the correct way to proceed ?
Would be great if a fix was directly integrated in Titanium for\nnext release.
I am still trying to find a solution for this issue.
\nI feel that the problem is similar to this one (#1342), which has\nbeen resolved in 1.5. The difference is that instead of having\ncustom labels, we have a kind of default label 'email'.
\nAny clue on how to fix that ? I did not manage to fix it with the\nsolution provided.
OK, this has been reported often enough that I can't dismiss it\nas user error any more. Also, there's sample code now.
We are having the same issue with address. It seems that any\ncontact created from the iOS Maps App does not set the label on\naddress. To test, using the following code on device. Click 'Test\nContacts' and see if it crashes. If it does, look in the console to\nsee what the last contact was. If it doesn't, do a maps search for\nany business, add as a contact, and then run again. Built with 1.6\nrunning on 4.2, this consistently crashed the app. Then, change the\nnew contacts address to 'other' and try again.
\n\nvar win = Titanium.UI.createWindow();\nvar button = Ti.UI.createButton({\nwidth:150,\nheight:50,\ntitle:'Test Contacts'\n});\nwin.add(button);\nbutton.addEventListener('click', function(){\nvar people = Titanium.Contacts.getAllPeople();\n for (var i = 0, all = people.length; i < all; i++) \n {\n Ti.API.info('Working on contact '+i+', '+people[i].fullName);\n for (var label in people[i].email) {\n var addrs = people[i].email[label];\n Ti.API.info(\"Email: \"+people[i].email[label]);\n }\n for (var label in people[i].address) {\n var addrs = people[i].address[label];\n for (var ii = 0; ii < addrs.length; ii++) \n {\n if (addrs[ii].Street != undefined && addrs[ii].Street.length > 1)\n {\n Ti.API.info(\" address[\"+label+\"]: \"+addrs[ii].Street);\n }\n }\n }\n }\n alert('Contacts Successfully Tested');\n});\nwin.open();
\n
\nTicket Reference: http://developer.appcelerator.com/helpdesk/view/76124
This issue needs to be resolved for us to release our app.
\nWe are still working on some other items to make the app ready but\nwe need to know this is going to get some attention soon.
Is there a plan or is this scheduled as a priority?
(from [42a8c3893133671e0d98d55ab556ff24966d888f])\n[#2317 state:fixed-in-qa\nmilestone:\"Sprint-2011-11\"][#1849 state:fixed-in-qa\nmilestone:Sprint-2011-11][#1958 state:fixed-in-qa\nmilestone:Sprint-2011-11] Numerous fixes for crashers in Contacts.\n\nhttps://github.com/appcelerator/titanium_mobile/commit/42a8c3893133...
Awesome - glad to see this has a resolution path!
\nHow can I relate milestones to builds available via the\ncontinuous builds page to know if a particular build includes the\nfix?
Tested with Titanium SDK version: 1.7.0 (03/18/11 12:00 19be393)\non
\nSimulator 4.0
\niPad2 4.3