dagnytaggart
dagnytaggart

Reputation: 521

CALayer position contains NaN: [nan -0.5]

I see this log in the console when I run my app:

CALayer position contains NaN: [nan -0.5]

The app consists of a UITaBar of which the first tab is a UINavigationController. In the NavController I'm launching the AddressBookPicker. In the AddressBookPicker I'm only choosing to show phone numbers.

When I choose on a contact that has only email addresses, that is when I see this log.

I do not see any crashes or any issues for that matter, just the log printed onto the console. Want to make sure that this is not a hidden issue that crashes on me after the launch.

Below is a snippet of relevant code and the stacktrace. Not sure which other parts of the code to paste here, please let me know if there are any I can post that might help.

Any help/inputs appreciated.

Thanks!

Code

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

NSArray *displayedItems = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonPhoneProperty]), nil];

picker.displayedProperties = displayedItems;

picker.peoplePickerDelegate = self;

[self presentModalViewController:picker animated:YES];

Stacktrace

#0    0x00096377 in NSLog

#1    0x046b38c9 in CALayerSetPosition

#2    0x046b3846 in -[CALayer setPosition:]

#3    0x046b375f in -[CALayer setFrame:]

#4    0x002f510b in -[UIView(Geometry) setFrame:]

#5    0x003dbe6d in -[UILabel setFrame:]

#6    0x023ed095 in -[ABPersonTableViewDataSource reloadNoValueLabelAnimated:]

#7    0x0244cf53 in -[ABPersonTableViewDataSource reloadDataIncludingHeaderView:invalidatePropertyData:]

#8    0x023f30d4 in -[ABPersonTableViewDataSource reloadDataIncludingHeaderView:]

#9    0x023eabc9 in -[ABPersonViewControllerHelper prepareViewWithDisplayedProperties:person:allowActions:]

#10    0x023ea6bc in -[ABPersonViewControllerHelper loadViewWithDisplayedProperties:person:allowDeletion:allowActions:]

#11    0x023ea598 in -[ABPersonViewController loadView]

#12    0x0036a54f in -[UIViewController view]

#13    0x003689f4 in -[UIViewController contentScrollView]

#14    0x003787e2 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]

#15    0x00376ea3 in -[UINavigationController _layoutViewController:]

#16    0x0037812d in -[UINavigationController _startTransition:fromViewController:toViewController:]

#17    0x00372ccd in -[UINavigationController _startDeferredTransitionIfNeeded]

#18    0x00379d8b in -[UINavigationController pushViewController:transition:forceImmediate:]

#19    0x00372b67 in -[UINavigationController pushViewController:animated:]

#20    0x02403bc2 in -[ABPeoplePickerNavigationController pushViewController:animated:]

#21    0x0242a424 in -[ABPeoplePickerNavigationController showCardForPerson:withMemberCell:animate:forceDisableEditing:personViewController:]

#22    0x0242ce20 in -[ABMembersViewController showCardForPerson:withMemberCell:animate:]

#23    0x0240a0ef in -[ABMembersController abDataSource:selectedPerson:atIndexPath:withMemberCell:animate:]

#24    0x023fdb47 in -[ABMembersDataSource tableView:didSelectRowAtIndexPath:]

#25    0x00333a48 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]

#26    0x0032a32e in -[UITableView _userSelectRowAtIndexPath:]

#27    0x0003f21a in __NSFireDelayedPerform

#28    0x02631f73 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__

#29    0x026335b4 in __CFRunLoopDoTimer

#30    0x0258fdd9 in __CFRunLoopRun

#31    0x0258f350 in CFRunLoopRunSpecific

#32    0x0258f271 in CFRunLoopRunInMode

#33    0x02f2f00c in GSEventRunModal

#34    0x02f2f0d1 in GSEventRun

#35    0x002ceaf2 in UIApplicationMain

#36    0x00002554 in main at main.m:14

Upvotes: 7

Views: 8584

Answers (4)

jaimeat
jaimeat

Reputation: 11

I had the same problem with "CALayer position contains NaN:". The app was fine in iOS3.x and iOS4.1 devices, but crashed in iOS4.2.

In my case, I has the following code:

CGRect frame;
frame.size.height = kTableCellHeight - 11;
frame.size.width = widthCell - 30;

UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:frame];

The UILabel creation failed and shown that error. In my case, it was solved adding arbitrary values for frame.origin (for this UILabel purpose, it didn't matter)

CGRect frame;
frame.size.height = kTableCellHeight - 11;
frame.size.width = widthCell - 30;
frame.origin.x = 0;
frame.origin.y = 0;

UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:frame];

Maybe the problem with "CALayer position contains NaN" is because some nil, incomplete or undefined value or structure is being used.

Upvotes: 1

Brad Shuttleworth
Brad Shuttleworth

Reputation: 357

I'm having the same problem, though it doesn't appear to happen in the built in apps (eg. mail).

One slightly hackish workaround is to add the First and Last names to the list of displayed properties - it doesn't show the "no email address" layer in that case, but also doesn't crash.

Upvotes: 1

jsrivo
jsrivo

Reputation: 11

This seems to now cause crashes in iOS 4.2. Try picking a contact with no phone number, you should go to a view that says No Phone numbers. The crash occurs when you go back to All Contacts then pick that contact again.

Is anyone else experiencing this problem?

edit: In my case, I am only displaying email addresses. Picking a contact without an email address twice causes the crash.

Upvotes: 1

Brad
Brad

Reputation: 11505

  1. I don't know.

  2. I see this too - I am doing something completely different from you - I am using the route-me mapping engine to display scrollable maps.

I believe it has something to do with scrolling views - and a layer somehow involved in the scrolling. As some of the views you mentioned I believe are scrolling - this would concur with my observations.

I wish I had more data for you, but one thing I can tell you is that I have been working on the app for months, and have been testing it on the iPhone and iPad, devices and simulator, under OSes 3.2 and 4.0 - and have had no crashes or memory leaks [at all, or associated with this].

So in short - no idea - but I think you're okay!

Upvotes: 0

Related Questions