Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 441
Mundi Avatar asked Oct 20 '25 16:10

Mundi


1 Answers

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.
like image 107
TwoStraws Avatar answered Oct 23 '25 07:10

TwoStraws



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!