-1

I inherited an iOS app written targeting iOS 6 (last worked on before iOS 7 came out).

When it was last worked on, Xcode (version 4, I'm guessing) was able to compile and run it on the iPhone 5 simulator, among other things.

I'm now trying to resurrect it, in Xcode 6, trying to run it again on iPhone 5 simulator (since it's not built to run on x64 yet, this is the latest phone I can run it on).

It uses Storyboards.

Where I'm at now is one of the view controllers is having it's viewDidLoad method called repeatedly. When I pause the debugger at the top of that method, I see this stack trace below.

Any ideas on how to debug this further, so I can identify the reason it's being called repeatedly? I have searched all of the code and do not see it being explicitly called, and the stack trace (below) doesn't seem to provide any clues. I'm guessing due to Storyboard Magic®?

UPDATE: The viewDidLoad method in question has now been reduced to only calling [super viewDidLoad]; and it still exhibits this problem. I'm not sure why people are voting to close this, as no comments are being given about that. To be clear, the stack trace is not from a crash, it's the trace at the top of the viewDidLoad method which keeps getting hit repeatedly. There is no increase in memory, and the program doesn't seem to crash, so I don't think anything recursive is happening, FWIW.

* thread #1: tid = 0x19e5f8, 0x001305de Company`-[CompanyiPhoneMapViewController viewDidLoad](self=0x7c2ecc00, _cmd=0x02d8ebf4) + 78 at CompanyiPhoneMapViewController.m:519, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x001305de Company`-[CompanyiPhoneMapViewController viewDidLoad](self=0x7c2ecc00, _cmd=0x02d8ebf4) + 78 at CompanyiPhoneMapViewController.m:519
    frame #1: 0x025b62a4 UIKit`-[UIViewController loadViewIfRequired] + 771
    frame #2: 0x025ec0ed UIKit`-[UINavigationController _layoutViewController:] + 42
    frame #3: 0x025ec65c UIKit`-[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
    frame #4: 0x025ec760 UIKit`-[UINavigationController _startTransition:fromViewController:toViewController:] + 90
    frame #5: 0x025ed6fb UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 669
    frame #6: 0x025ee372 UIKit`-[UINavigationController __viewWillLayoutSubviews] + 57
    frame #7: 0x0276204c UIKit`-[UILayoutContainerView layoutSubviews] + 213
    frame #8: 0x024e9dd1 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
    frame #9: 0x03cb1771 libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70
    frame #10: 0x0201128f QuartzCore`-[CALayer layoutSublayers] + 152
    frame #11: 0x02005115 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 397
    frame #12: 0x02004f70 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26
    frame #13: 0x01f633c6 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 284
    frame #14: 0x01f6478c QuartzCore`CA::Transaction::commit() + 392
    frame #15: 0x0202a799 QuartzCore`+[CATransaction flush] + 52
    frame #16: 0x02487ceb UIKit`_afterCACommitHandler + 126
    frame #17: 0x03f359de CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    frame #18: 0x03f35920 CoreFoundation`__CFRunLoopDoObservers + 400
    frame #19: 0x03f2b35a CoreFoundation`__CFRunLoopRun + 1226
    frame #20: 0x03f2abcb CoreFoundation`CFRunLoopRunSpecific + 443
    frame #21: 0x03f2a9fb CoreFoundation`CFRunLoopRunInMode + 123
    frame #22: 0x04cd424f GraphicsServices`GSEventRunModal + 192
    frame #23: 0x04cd408c GraphicsServices`GSEventRun + 104
    frame #24: 0x0245e8b6 UIKit`UIApplicationMain + 1526
    frame #25: 0x000b63dd Company`main(argc=1, argv=0xbff4b4c0) + 141 at main.m:16
    frame #26: 0x0477aac9 libdyld.dylib`start + 1
Mason G. Zhwiti
  • 6,444
  • 11
  • 61
  • 97
  • 1
    It would help if you posted the code for `CompanyiPhoneMapViewController viewDidLoad` and point out line 519. – rmaddy Dec 11 '14 at 23:55
  • @rmaddy 519 was the line number of the breakpoint I set. I have this problem even with a nearly empty viewDidLoad (i.e. the only thing I now have in my viewDidLoad is the call to `[super viewDidLoad];` – Mason G. Zhwiti Dec 12 '14 at 17:27
  • 1
    Why the downvotes? He has a programming related question, asks for assistance, not solutions, and clearly states why he is unable to provide more information. He even asks in the question title on "how to diagnose" his problem... – Philipp Dec 12 '14 at 18:32

1 Answers1

0

I still haven't figured out what precisely is triggering this to load repeatedly, but I did locate a debugging technique that has helped me work around the issue.

By examining the output from this debugging technique, I was able to see other methods being called repeatedly (still for unknown reasons), which eventually lead me to fix a piece of buggy code... which did end up stopping the repeated calls to viewDidLoad in the class above.

I am not going to mark this as an answer quite yet, as someone may know of some better techniques to truly identify the culprit.

If anyone knows how to get Instruments to profile things in a way where you can get a sorted list of "most often called methods," this might be another indirect way of tracking down similar issues.

Community
  • 1
  • 1
Mason G. Zhwiti
  • 6,444
  • 11
  • 61
  • 97