SwiftUI App crashes in main method on Startup (macOS 11)

Hi,
my app sees quite a lot of crashes (crash report below) and I have no clue how to debug the problem any further.

The problems seems only to occur on macOS 11. Is there anyone als having this kind of problems? Are there fixes/workarounds?

The source code of my app is open source if anyone would like to have a look into it.

Code Block
OS Version: macOS 11.2.2 (20D80)
Report Version: 104
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: ILL_NOOP at 0x00007fff2ca430f4
Crashed Thread: 0
Application Specific Information:
Fatal error > SwiftUI
Thread 0 Crashed:
0 libswiftCore.dylib 0xfffe591310f4 _assertionFailure
1 SwiftUI 0xfffe8516c6fc ViewCache.commitPlacedChildren
2 SwiftUI 0xfffe850727f4 IncrementalChildPlacements.updateValue
3 SwiftUI 0xfffe8512890e Attribute.init<T>
4 AttributeGraph 0xfffe8625b17e AG::Graph::UpdateStack::update
5 AttributeGraph 0xfffe8625b607 AG::Graph::update_attribute
6 AttributeGraph 0xfffe862638f2 AG::Subgraph::update
7 SwiftUI 0xfffe85463679 GraphHost.runTransaction
8 SwiftUI 0xfffe85464bce GraphHost.runTransaction
9 SwiftUI 0xfffe85463ec8 GraphHost.flushTransactions
10 SwiftUI 0xfffe85464b6e GraphHost.asyncTransaction<T>
11 SwiftUI 0xfffe85464738 @callee_guaranteed
12 SwiftUI 0xfffe84d172b0 ViewGraphDelegate.updateGraph<T>
13 SwiftUI 0xfffe853201b9 ViewRendererHost.updateViewGraph<T>
14 SwiftUI 0xfffe8531e2a8 ViewRendererHost.updateViewGraph<T>
15 SwiftUI 0xfffe85329e98 NSHostingView<T>
16 SwiftUI 0xfffe84d12f06 ViewGraphDelegate.updateGraph<T>
17 SwiftUI 0xfffe84d17258 NSHostingView<T>
18 SwiftUI 0xfffe85464b49 GraphHost.init
19 SwiftUI 0xfffe84d18c9b @callee_guaranteed
20 SwiftUI 0xfffe8537a250 @callee_guaranteed
21 SwiftUI 0xfffe85377ee5 NSRunLoop.flushObservers
22 SwiftUI 0xfffe8537a198 NSRunLoop.addObserver
23 SwiftUI 0xfffe853755fd @callee_guaranteed
24 libswiftObjectiveC.dylib 0xfffe66ed2d9d autoreleasepool<T>
25 SwiftUI 0xfffe8537a182 NSRunLoop.addObserver
26 SwiftUI 0xfffe8537a1ca NSRunLoop.addObserver
27 CoreFoundation 0xfffe40ab4dac __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
28 CoreFoundation 0xfffe40ab4c3c __CFRunLoopDoObservers
29 CoreFoundation 0xfffe40ab3745 CFRunLoopRunSpecific
30 HIToolbox 0xfffe5101162f RunCurrentEventLoopInMode
31 HIToolbox 0xfffe5101142b ReceiveNextEventCommon
32 HIToolbox 0xfffe5101114e _BlockUntilNextEventMatchingListInModeWithFilter
33 AppKit 0xfffe45b349b0 _DPSNextEvent
34 AppKit 0xfffe45b33176 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
35 AppKit 0xfffe45b25689 -[NSApplication run]
36 AppKit 0xfffe45af996e NSApplicationMain
37 SwiftUI 0xfffe84ab59f3 runApp
38 SwiftUI 0xfffe8534c791 runApp<T>
39 SwiftUI 0xfffe84ecb09c App.main
40 PDFArchiver 0x2067699b0 [inlined] PDFArchiverApp.$main
41 PDFArchiver 0x2067699b0 main
42 libdyld.dylib 0xfffe40967620 start





Hi! Working with SwiftUI that same issue happened to us when having lists (using ForEach) with the same id. Imagine that you have a ForEach to present a list of people, if you use as id the name of the person, can happen that several people have John as id.
Be careful if you are mocking those items, that was what happened to us. We were mocking Models with the same id.

Hope it helps!
It would be nice if these crash logs included which view was having this issue.

From what I have seen, this error seems to be related specifically to ForEach and list's with duplicate IDs. However without any idea of which list this is happening in, it's incredibly difficult to debug.

A lot of swiftUI crashes are incredibly hard to debug. I hope there are some improvements in this regard with this in iOS 15.

This no longer results in a crash. I get the following message in the console, when multiple elements have the id as nil inside a List.

ForEach<Array<ArrayData>, Optional<Int>, Text>: the ID nil occurs multiple times within the collection, this will give undefined results!

Make sure the identifiers are unique, if not multiple views will look the same but it will not crash.

SwiftUI App crashes in main method on Startup (macOS 11)
 
 
Q