How to debug exceptions from inside the SwiftUI framework

Stack trace looks like this and I completely have no idea on where the problem is.

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000195bafb64
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [1776]

Triggered by Thread:  0


Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage


Thread 0 name:
Thread 0 Crashed:
0   SwiftUI                       	0x0000000195bafb64 ViewCache.item(data:) + 3492 (IncrementalLayout.swift:0)
1   SwiftUI                       	0x000000019619318c closure #2 in IncrementalStack<>.prefetch(children:edges:context:state:) + 64 (IncrementalLayout.swift:514)
2   SwiftUI                       	0x000000019702a960 $s7SwiftUI6HVGrid33_31F43AFD49DC183BC0BAE157829FFC07LLPAAE5place8children6length13minorGeometry4emitySayAA24_IncrementalLayout_ChildVG_12CoreGraphics7CGFloatVSgSayAA0cN0ACLLVGyAK_So7CGPointVAA13_Pr... + 200
3   SwiftUI                       	0x000000019702abc8 protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyHGridLayout + 76
4   SwiftUI                       	0x000000019702ab70 protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyVGridLayout + 56
5   SwiftUI                       	0x0000000195d67c24 $s7SwiftUI16IncrementalStackPA2A01_cD6_StateVyxG0E0RtzrlE8prefetch8children5edges7context5stateyAA01_C15Layout_ChildrenV_AA4EdgeO3SetVAA01_cK17_PlacementContextVAFtFAA09LazyVGridK033_31F43AFD49DC18... + 340 (IncrementalStack.swift:700)
6   SwiftUI                       	0x0000000195d720fc specialized closure #1 in closure #1 in IncrementalChildPrefetcher.updateValue() + 444 (<compiler-generated>:0)
7   SwiftUI                       	0x0000000195d71ce4 specialized IncrementalChildPrefetcher.updateValue() + 216
8   SwiftUI                       	0x0000000195f998e4 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 44 (<compiler-generated>:0)
9   AttributeGraph                	0x00000001b4edb6f4 AG::Graph::UpdateStack::update() + 520 (ag-closure.h:109)
10  AttributeGraph                	0x00000001b4edaf44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:714)
11  AttributeGraph                	0x00000001b4ed9c00 AG::Subgraph::update(unsigned int) + 844 (ag-subgraph.cc:734)
12  SwiftUI                       	0x0000000195ac0f28 GraphHost.flushTransactions() + 572 (GraphHost.swift:640)
13  SwiftUI                       	0x0000000195b8be30 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
14  SwiftUI                       	0x00000001964bd7fc static Update.dispatchActions() + 572 (<compiler-generated>:0)
15  SwiftUI                       	0x0000000195abc850 static Update.end() + 116 (Update.swift:58)
16  SwiftUI                       	0x0000000196a863bc SystemScrollViewPrefetchState.commit(to:) + 344 (Update.swift:71)
17  SwiftUI                       	0x0000000196cee688 HostingScrollView._updateCycleIdle(until:) + 208 (HostingScrollView_PhoneTVWatch.swift:632)
18  SwiftUI                       	0x0000000196cee6c8 @objc HostingScrollView._updateCycleIdle(until:) + 40 (<compiler-generated>:0)
19  UIKitCore                     	0x000000019434694c ___UIUpdateCycleNotifyIdle_block_invoke + 612 (_UIUpdateCycleIdleScheduler.m:148)
20  libdispatch.dylib             	0x00000001996e04b4 _dispatch_call_block_and_release + 32 (init.c:1518)
21  libdispatch.dylib             	0x00000001996e1fdc _dispatch_client_callout + 20 (object.m:560)
22  libdispatch.dylib             	0x00000001996f07f4 _dispatch_main_queue_drain + 928 (inline_internal.h:2632)
23  libdispatch.dylib             	0x00000001996f0444 _dispatch_main_queue_callback_4CF + 44 (queue.c:7887)
24  CoreFoundation                	0x00000001921a26f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
25  CoreFoundation                	0x0000000192184058 __CFRunLoopRun + 2036 (CFRunLoop.c:3147)
26  CoreFoundation                	0x0000000192188ed4 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
27  GraphicsServices              	0x00000001cb48a368 GSEventRunModal + 164 (GSEvent.c:2196)
28  UIKitCore                     	0x00000001946673d0 -[UIApplication _run] + 888 (UIApplication.m:3745)
29  UIKitCore                     	0x0000000194667034 UIApplicationMain + 340 (UIApplication.m:5335)
30  SwiftUI                       	0x0000000195c74014 closure #1 in KitRendererCommon(_:) + 168 (UIKitApp.swift:37)
31  SwiftUI                       	0x0000000195bd516c runApp<A>(_:) + 152 (<compiler-generated>:0)
32  SwiftUI                       	0x0000000195bbe4bc static App.main() + 128 (App.swift:114)
33  ProductName                     	0x0000000104aa3ba8 static ProductName.$main() + 52 (ProductName.swift:13)
34  ProductName                     	0x0000000104aa3ba8 main + 64 (AdView.swift:0)
35  dyld                          	0x00000001b07f0960 start + 2528 (dyldMain.cpp:1170)

It looks like something about ScrollView, but how can i find the exact ScrollView?

Any news on this?

Any update here on possible workarounds? I am seeing these crashes constantly in my app with SwiftUI. Really a horrible experience for our users - hard to believe core SwiftUI components could be this unstable. Filed feedback FB11800180

Date/Time:           2023-01-19 09:19:49.9921 -0500
Launch Time:         2023-01-19 09:11:40.5629 -0500
OS Version:          iPhone OS 16.2 (20C65)
Release Type:        User
Baseband Version:    2.21.00
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001aa0aae78
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [39631]

Triggered by Thread:  0


Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage


Thread 0 name:
Thread 0 Crashed:
0   SwiftUI                       	0x00000001aa0aae78 ViewCache.item(data:) + 3484 (IncrementalLayout.swift:0)
1   SwiftUI                       	0x00000001aa692894 closure #2 in IncrementalStack<>.prefetch(children:edges:context:state:) + 64 (IncrementalLayout.swift:514)
2   SwiftUI                       	0x00000001ab531944 $s7SwiftUI6HVGrid33_31F43AFD49DC183BC0BAE157829FFC07LLPAAE5place8children6length13minorGeometry4emitySayAA24_IncrementalLayout_ChildVG_12CoreGraphics7CGFloatVSgSayAA0cN0ACLLVGyAK_So7CGPointVAA13_Pr... + 200
3   SwiftUI                       	0x00000001ab531bac protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyHGridLayout + 76
4   SwiftUI                       	0x00000001ab531b54 protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyVGridLayout + 56
5   SwiftUI                       	0x00000001aa2637d8 $s7SwiftUI16IncrementalStackPA2A01_cD6_StateVyxG0E0RtzrlE8prefetch8children5edges7context5stateyAA01_C15Layout_ChildrenV_AA4EdgeO3SetVAA01_cK17_PlacementContextVAFtFAA09LazyVGridK033_31F43AFD49DC18... + 340 (IncrementalStack.swift:700)
6   SwiftUI                       	0x00000001aa26daa0 specialized closure #1 in closure #1 in IncrementalChildPrefetcher.updateValue() + 444 (<compiler-generated>:0)
7   SwiftUI                       	0x00000001aa26d688 specialized IncrementalChildPrefetcher.updateValue() + 216
8   SwiftUI                       	0x00000001aa492a08 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 44 (<compiler-generated>:0)
9   AttributeGraph                	0x00000001c95f86f4 AG::Graph::UpdateStack::update() + 520 (ag-closure.h:109)
10  AttributeGraph                	0x00000001c95f7f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:714)
11  AttributeGraph                	0x00000001c95f6c00 AG::Subgraph::update(unsigned int) + 844 (ag-subgraph.cc:734)
12  SwiftUI                       	0x00000001a9fbf4a8 GraphHost.flushTransactions() + 572 (GraphHost.swift:640)
13  SwiftUI                       	0x00000001aa087134 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
14  SwiftUI                       	0x00000001aa978108 static Update.dispatchActions() + 572 (<compiler-generated>:0)
15  SwiftUI                       	0x00000001a9fbade8 static Update.end() + 116 (Update.swift:58)
16  SwiftUI                       	0x00000001aaf447ac SystemScrollViewPrefetchState.commit(to:) + 344 (Update.swift:71)
17  SwiftUI                       	0x00000001ab1ae314 HostingScrollView._updateCycleIdle(until:) + 208 (HostingScrollView_PhoneTVWatch.swift:632)
18  SwiftUI                       	0x00000001ab1ae354 @objc HostingScrollView._updateCycleIdle(until:) + 40 (<compiler-generated>:0)
19  UIKitCore                     	0x00000001a8836544 ___UIUpdateCycleNotifyIdle_block_invoke + 612 (_UIUpdateCycleIdleScheduler.m:148)
20  libdispatch.dylib             	0x00000001adbfb4b4 _dispatch_call_block_and_release + 32 (init.c:1518)
21  libdispatch.dylib             	0x00000001adbfcfdc _dispatch_client_callout + 20 (object.m:560)
22  libdispatch.dylib             	0x00000001adc0b7f4 _dispatch_main_queue_drain + 928 (inline_internal.h:2632)
23  libdispatch.dylib             	0x00000001adc0b444 _dispatch_main_queue_callback_4CF + 44 (queue.c:7887)
24  CoreFoundation                	0x00000001a667a6d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
25  CoreFoundation                	0x00000001a665c03c __CFRunLoopRun + 2036 (CFRunLoop.c:3147)
26  CoreFoundation                	0x00000001a6660ec0 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
27  GraphicsServices              	0x00000001e06b7368 GSEventRunModal + 164 (GSEvent.c:2196)
28  UIKitCore                     	0x00000001a8b5686c -[UIApplication _run] + 888 (UIApplication.m:3754)
29  UIKitCore                     	0x00000001a8b564d0 UIApplicationMain + 340 (UIApplication.m:5344)
30  Alinea                        	0x00000001023f6da0 main + 68 (AppDelegate.swift:28)
31  dyld                          	0x00000001c4e82960 start + 2528 (dyldMain.cpp:1170)

Same here

Our app crashed with a similar stack trace. I found the cause and fixed it. You can see my answer in this post: Debugging SwiftUI Framework crash. Hope it helps

How to debug exceptions from inside the SwiftUI framework
 
 
Q