Mundi
Mundi

Reputation: 80271

How to debug infinite loop "crash" in Xcode for iOS involving CALayer and view layout during search?

My app is hanging during search in a table view.

For what it's worth, the view hierarchy is very complex, there are popovers involved as well as filters and search bars etc. I am reviewing all those possibilities.

But the non-crash - it's an infinite loop - occurs when the search results table is being displayed / updated, after a call to reloadData.

Here is what I get when I stop the program and look at the main thread:

enter image description here

You can see - it involves UIView, CALayer, CATransaction. I have no clue how to get back to my controller classes to find the offending code.

Any hints, suggestions, wild guesses welcome!

EDIT Here is more - some more classes appearing when I interrupt at some other random point.

enter image description here

Upvotes: 4

Views: 3954

Answers (1)

TwoStraws
TwoStraws

Reputation: 13127

This is an old question, but in case other folks arrive here: it's possible you're facing a layout feedback loop. I wrote an article about how to debug these (link: Debugging Auto Layout feedback loops) but here's a summary:

  • If you modify your layouts during layout, or if you have ambiguous layout, you might find yourself stuck in a loop.
  • Apple discussed a special debugging technique at WWDC 2016 – skip to about 15 minutes before the end, and they introduce the layout feedback loop debugger.
  • To try it yourself, add -UIViewLayoutFeedbackLoopDebuggingThreshold 100 to the list of launch arguments for your app, then run it again.
  • When the error happens next time, you should get (a lot of) debugging information that helps point you in the right direction.

Upvotes: 12

Related Questions