1

The whole Storyboard is AutoLayout enabled.

When I put a log inside viewDidLayoutSubviews(), I can see it's called repeatedly, and never stops.

I don't have any auto layout red flags in the view controller.

What could be causing this? What would be the best way to debug this?...to find out which view is struggling?


UPDATE

It turned out to be a UILabel making this trouble. Even though it has all 4 constraints (x, y, width, height) It seem to be calling re layouts up the tree......

Gizmodo
  • 3,151
  • 7
  • 45
  • 92
  • 4
    This problem is _very_ well discussed in video 236 of WWDC 2016. Please take a look. Apart from that, impossible to help you if you _don't show the code_. You have something in your `viewDidLayoutSubviews` that causes recursion, but you _don't show it_. – matt Mar 07 '17 at 18:15
  • Use -UIViewLayoutFeedbackLoopDebuggingThreshold launch argument. Set the value to anywhere between 50...1000. If you indeed have a feedback loop, the debugger will collect info about this after the threshold value has been reached, raise an exception and stick the collected info into the log (com.apple.uisubsystem) – Yohst Mar 07 '17 at 18:52

2 Answers2

1

My best guess is that it would be related to how subviews are laid out in the storyboard. Maybe some erroneous wiring of the views. It's hard to help you out on this without some more context about how your views and view controllers are laid out. Do you have some code sample or storyboard that you could share?

You can try using the View Debugger tool in Xcode. I have not used this myself for debugging, besides just trying it out to see my view hierarchy. Start by putting a breakpoint the in the viewDidLayoutSubviews and observe how the hierarchy changes every time it's called.https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • Is there a way to debug this? In Instruments? Or within Xcode it self? – Gizmodo Mar 07 '17 at 18:54
  • 1
    You can try using the **View Debugger** tool in Xcode. I have not used this myself for debugging, besides just trying it out to see my view hierarchy. Start by putting a breakpoint the in the **viewDidLayoutSubviews** and observe how the hierarchy changes every time it's called.https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html – Kiran Dwarkan Mar 07 '17 at 19:00
0

If maybe you have some loops change the view property over and over again in some subviews. Check it and find it out. Stop it.

J. Sue
  • 79
  • 9
  • Found out this is due to a UILabel. Eventhough that label has all 4 constraints (x, y, width, height) it still seems to call viewDidLayoutSubviews in up the tree... – Gizmodo Mar 08 '17 at 16:33