1

I've been stuck on this thing for many hours now and I don't know what else to search for.

There's not much I can provide since the debugger doesn't show any errors but it's reproducible--I tap on a very specific item in a table view, the act of which should dismiss that modal, and then my app freezes. That doesn't happen for the other items in the table view--the modal dismisses perfectly and the app goes on.

I checked this answer suspecting that it's a deadlock, however:

  • Everytime I hit the pause button in the debugger, the main thread is up to something different.
  • The CPU usage as seen from Xcode's Debug navigator increases over time.
  • I put breakpoints at one of my custom UIControl's layoutSubviews method and it keeps getting called. It does not call [super layoutSubviews], does not call setNeedsLayout on anyone, and simply sets the frames of its subviews because I'm not using Autolayout.

How can I debug this thing? I've been looking around Xcode Instruments but I can't make sense of the data I'm seeing. The System Trace template, specifically, seems capable of stopping right when the freeze occurs, unlike the others which keep on recording.

Added: What I see in System Trace What I see in System Trace

Community
  • 1
  • 1
Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132
  • 1
    Did you check for recursive method calling after tapping on that cell. Add some code – Sumanth Apr 14 '15 at 05:24
  • Can you confirm you're not manipulating UI from a background thread? didSelectRowAtIndexPath is not called on the main thread in all circumstances (http://stackoverflow.com/a/22173707/80678) – kenleycapps Apr 14 '15 at 05:27
  • @kenleycapps Nope, didSelectRowAtIndexPath isn't running in a background thread. It's running on the main thread, no dispatch_asyncs in there. – Matthew Quiros Apr 14 '15 at 05:42
  • 1
    The time profiler instrument will probably be more useful. Select "invert call tree" and "hide system libraries" and see what it shows – Paulw11 Apr 14 '15 at 05:56

2 Answers2

2

Instruments is the tool you want to diagnose the issue. Try inspecting your app with Time Profiler, performing the task that you were observing to increase CPU usage and then analyze the results, checking Invert Call Tree and Hide System Libraries. You can also set time markers if there is a specific time period you are looking to inspect. From here, you can see what calls are sucking up the CPU.

nmock
  • 1,907
  • 2
  • 20
  • 29
0

@Paulw11's comment helped--the Time Profiler template is better suited for this task than the System Trace instrument.

I used the Time Profiler and got led to a bunch of traces that point to the UINavigationBar as the suspect repetitive caller to my custom UIControl's layoutSubviews. To further explain my view hierarchy:

  • My "Home" view controller has a custom title view in its UINavigationItem
  • The custom title view is a custom UIControl that launches a modal when tapped

Here's the deal: If I alloc-initWithFrame my custom UIControl with a frame of CGRectZero, the app freezes. If I provide a garbage initial value to the frame (which is disregarded anyway since UINavigationBar reshapes my custom UIControl) like CGRectMake(0, 0, 10, 10), the crash doesn't happen.

I'm guessing that UINavigationBar gets confused about how to layout a custom title view that has an initial frame of (0, 0, 0, 0). Sounds like an Apple bug.

Note: I'm running on iOS 8.2.

Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132