Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug SwiftUI AttributeGraph cycle warnings?

I'm getting a lot of AttributeGraph cycle warnings in my app that uses SwiftUI. Is there any way to debug what's causing it?

This is what shows up in the console:

=== AttributeGraph: cycle detected through attribute 11640 ===
=== AttributeGraph: cycle detected through attribute 14168 ===
=== AttributeGraph: cycle detected through attribute 14168 ===
=== AttributeGraph: cycle detected through attribute 44568 ===
=== AttributeGraph: cycle detected through attribute 3608 ===
like image 994
Sindre Sorhus Avatar asked Jul 13 '20 05:07

Sindre Sorhus


3 Answers

The log is generated by (from private AttributeGraph.framework)

AG::Graph::print_cycle(unsigned int) const ()

so you can set symbolic breakpoint for print_cycle

demo

and, well, how much it could be helpful depends on your scenario, but definitely you'll get error generated stack in Xcode.

like image 115
Asperi Avatar answered Sep 20 '22 17:09

Asperi


For me this issue was caused by me disabling a text field while the user was still editing it.

To fix this, you must first resign the text field as the first responder (thus stopping editing), and then disable the text field. I explain this more in this Stack Overflow answer.

like image 25
wristbands Avatar answered Sep 21 '22 17:09

wristbands


For me, this issue was caused by trying to focus a TextField right before changing to the tab of a TabView containing the TextField.

It was fixed by simply focusing the TextField after changing the TabView tab.

This seems similar to what @wristbands was experiencing.

like image 23
Martin Avatar answered Sep 23 '22 17:09

Martin