Debugging SwiftUI Framework crash.

Hi everyone,

I am seeing a crash right now in my app that's related to the SwiftUI Framework. Has anyone else come across this crash? I can't reproduce the crash in my app and I've tried profiling my app to see if I could find ViewCache or IncrementalStack but they're nowhere to be found.

Here's the stacktrace

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

Triggered by Thread:  0


Kernel Triage:
VM - pmap_enter retried due to resource shortage


Thread 0 name:
Thread 0 Crashed:
0   SwiftUI                       	0x0000000191adae78 ViewCache.item(data:) + 3484 (IncrementalLayout.swift:0)
1   SwiftUI                       	0x00000001920c2894 closure #2 in IncrementalStack<>.prefetch(children:edges:context:state:) + 64 (IncrementalLayout.swift:514)
2   SwiftUI                       	0x0000000192f61944 $s7SwiftUI6HVGrid33_31F43AFD49DC183BC0BAE157829FFC07LLPAAE5place8children6length13minorGeometry4emitySayAA24_IncrementalLayout_ChildVG_12CoreGraphics7CGFloatVSgSayAA0cN0ACLLVGyAK_So7CGPointVAA13_Pr... + 200
3   SwiftUI                       	0x0000000192f61bac protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyHGridLayout + 76
4   SwiftUI                       	0x0000000192f61b54 protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyVGridLayout + 56
5   SwiftUI                       	0x0000000191c937d8 $s7SwiftUI16IncrementalStackPA2A01_cD6_StateVyxG0E0RtzrlE8prefetch8children5edges7context5stateyAA01_C15Layout_ChildrenV_AA4EdgeO3SetVAA01_cK17_PlacementContextVAFtFAA09LazyVGridK033_31F43AFD49DC18... + 340 (IncrementalStack.swift:700)
6   SwiftUI                       	0x0000000191c9daa0 specialized closure #1 in closure #1 in IncrementalChildPrefetcher.updateValue() + 444 (<compiler-generated>:0)
7   SwiftUI                       	0x0000000191c9d688 specialized IncrementalChildPrefetcher.updateValue() + 216
8   SwiftUI                       	0x0000000191ec2a08 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                	0x00000001b10286f4 AG::Graph::UpdateStack::update() + 520 (ag-closure.h:109)
10  AttributeGraph                	0x00000001b1027f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:714)
11  AttributeGraph                	0x00000001b1026c00 AG::Subgraph::update(unsigned int) + 844 (ag-subgraph.cc:734)
12  SwiftUI                       	0x00000001919ef4a8 GraphHost.flushTransactions() + 572 (GraphHost.swift:640)
13  SwiftUI                       	0x0000000191ab7134 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
14  SwiftUI                       	0x00000001923a8108 static Update.dispatchActions() + 572 (<compiler-generated>:0)
15  SwiftUI                       	0x00000001919eade8 static Update.end() + 116 (Update.swift:58)
16  SwiftUI                       	0x00000001929747ac SystemScrollViewPrefetchState.commit(to:) + 344 (Update.swift:71)
17  SwiftUI                       	0x0000000192bde314 HostingScrollView._updateCycleIdle(until:) + 208 (HostingScrollView_PhoneTVWatch.swift:632)
18  SwiftUI                       	0x0000000192bde354 @objc HostingScrollView._updateCycleIdle(until:) + 40 (<compiler-generated>:0)
19  UIKitCore                     	0x0000000190266544 ___UIUpdateCycleNotifyIdle_block_invoke + 612 (_UIUpdateCycleIdleScheduler.m:148)
20  libdispatch.dylib             	0x000000019562b4b4 _dispatch_call_block_and_release + 32 (init.c:1518)
21  libdispatch.dylib             	0x000000019562cfdc _dispatch_client_callout + 20 (object.m:560)
22  libdispatch.dylib             	0x000000019563b7f4 _dispatch_main_queue_drain + 928 (inline_internal.h:2632)
23  libdispatch.dylib             	0x000000019563b444 _dispatch_main_queue_callback_4CF + 44 (queue.c:7887)
24  CoreFoundation                	0x000000018e0aa6d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
25  CoreFoundation                	0x000000018e08c03c __CFRunLoopRun + 2036 (CFRunLoop.c:3147)
26  CoreFoundation                	0x000000018e090ec0 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
27  GraphicsServices              	0x00000001c80e7368 GSEventRunModal + 164 (GSEvent.c:2196)
28  UIKitCore                     	0x000000019058686c -[UIApplication _run] + 888 (UIApplication.m:3754)
29  UIKitCore                     	0x00000001905864d0 UIApplicationMain + 340 (UIApplication.m:5344)
30  Zumper                        	0x0000000104bfc064 main + 68 (AppDelegate.swift:38)
31  dyld                          	0x00000001ac8b2960 start + 2528 (dyldMain.cpp:1170)

I have the same problem, here is my stack trace as well from the crash organizer @eskimo 🙏

Our app is crashing with a similar stack trace. On iOS 16 a scroll view doesn't scroll back to position 0, when the content of the grid changes, which may cause the app to crash. In our case we display a list of items from a search request, which responds with 30 items of the total search result. Scrolling to the end, we load the next 30 items and so on. In a sticky view we display a set of buttons, that modifies the search parameters and causes to reload the whole screen, resulting in a list of 30 items. So lets say the view is displaying item at index 100 (4 page loads). Since the scroll view is not jumping back to the start position when hitting one of the quick filter buttons, the lazy grid tries to render the item at index 100 and crashes. I hope, this helps.

Debugging SwiftUI Framework crash.
 
 
Q