Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Crash due to likely infinitely recursive call in SwiftUI `Color.Resolved.init`

So I'm dealing with a really obtuse crash that appears to be a stack overflow in an internal SwiftUI code path creating a Color.Resolved. I haven't found anyone one else with this issue online, and I cannot get it to reproduce on my own device. Interestingly enough, it is only happening on 1 device in the field (according to XCode crash logs).

Here are some lines from the crashed thread. You can see that my code is never called, and it appears to be starting in some Array equality check checking the equality of colors (which I can't think of anywhere in my app I am doing anyway).

You can see from this trace here that it appears to be a recursive call through Color.Resolved and NSColor.withColorAppearance. I don't have any idea how to solve this, but it keeps happening with at least one in-the-field device across multiple app updates.

So my whole app is open source on github at https://github.com/msdrigg/roam, but I don't even use NSColor explicitly anywhere except for here which doesn't match the stack trace.

I also tried changing the accent color of the app with defaults write com.msdrigg.roam AppleAccentColor -integer 1 to see if that somehow caused the crash, but my app opened up totally fine (and respected the change). Besides this, the only places I think I could be using dynamic colors is I when define an AccentColor and a WidgetBackground color for my app using xcassets, and then I use these colors from SwiftUI. In most of my app I stick to the system colors (Color.gray and such).

Thread 0 Crashed:
0   libsystem_pthread.dylib       	0x000000018601213c ___chkstk_darwin + 60
1   CoreFoundation                	0x0000000186108434 -[NSArray isEqualToArray:] + 52 (NSArray.m:454)
2   AppKit                        	0x000000018a21fcd4 -[NSCoreUICatalogColor resolvedCUINamedColorForAppearance:] + 164 (NSColor.m:5057)
3   AppKit                        	0x0000000189c32cd4 -[NSCoreUICatalogColor resolvedColor] + 48 (NSColor.m:5148)
4   AppKit                        	0x0000000189c31e74 -[NSDynamicNamedColor colorUsingColorSpace:] + 32 (NSColor.m:4410)
5   SwiftUICore                   	0x0000000221ca9fd8 CoreColorPlatformColorGetComponents + 116 (CoreColorFunctions.m:149)
6   SwiftUICore                   	0x0000000221faaf28 specialized Color.Resolved.init(platformColor:) + 92 (CoreColor.swift:14)
7   SwiftUICore                   	0x0000000221faa5b0 Color.Resolved.init(platformColor:) + 16 (<compiler-generated>:0)
8   SwiftUI                       	0x00000001b53b1dc4 closure #1 in NSColor.resolve(in:) + 20 (AppKitColorConversions.swift:156)
9   SwiftUI                       	0x00000001b53b222c partial apply for closure #1 in static NSColor.withColorAppearance(in:_:) + 32 (<compiler-generated>:0)
10  SwiftUI                       	0x00000001b46b1e54 closure #1 in SubmitTriggerSource.dispatchUpdate(_:) + 28 (PlatformViewCoordinator.swift:12)
11  SwiftUI                       	0x00000001b5484488 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
12  AppKit                        	0x0000000189c174a4 +[NSAppearance _performWithCurrentAppearance:usingBlock:] + 72 (NSAppearance.m:2408)
13  SwiftUI                       	0x00000001b53b2088 specialized static NSColor.withColorAppearance(in:_:) + 324 (AppKitColorConversions.swift:142)
14  SwiftUI                       	0x00000001b53b1e7c protocol witness for ColorProvider.resolve(in:) in conformance NSColor + 68 (<compiler-generated>:151)
15  SwiftUICore                   	0x0000000222436e6c ColorBox.resolve(in:) + 124 (Color.swift:288)
16  SwiftUICore                   	0x0000000222435e30 Color.resolve(in:) + 72 (Color.swift:87)
17  SwiftUI                       	0x00000001b53b1c88 closure #1 in NSColor.init(_:) + 196 (AppKitColorConversions.swift:124)
18  SwiftUI                       	0x00000001b4542714 thunk for @escaping @callee_guaranteed (@guaranteed NSAppearance) -> (@owned NSColor) + 56 (<compiler-generated>:0)
19  AppKit                        	0x0000000189c31e74 -[NSDynamicNamedColor colorUsingColorSpace:] + 32 (NSColor.m:4410)
//// ... Repeating for 500 lines
500 SwiftUICore                   	0x0000000221ca9fd8 CoreColorPlatformColorGetComponents + 116 (CoreColorFunctions.m:149)
501 SwiftUICore                   	0x0000000221faaf28 specialized Color.Resolved.init(platformColor:) + 92 (CoreColor.swift:14)
502 SwiftUICore                   	0x0000000221faa5b0 Color.Resolved.init(platformColor:) + 16 (<compiler-generated>:0)
503 SwiftUI                       	0x00000001b53b1dc4 closure #1 in NSColor.resolve(in:) + 20 (AppKitColorConversions.swift:156)
504 SwiftUI                       	0x00000001b53b222c partial apply for closure #1 in static NSColor.withColorAppearance(in:_:) + 32 (<compiler-generated>:0)
505 SwiftUI                       	0x00000001b46b1e54 closure #1 in SubmitTriggerSource.dispatchUpdate(_:) + 28 (PlatformViewCoordinator.swift:12)
506 SwiftUI                       	0x00000001b5484488 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
507 AppKit                        	0x0000000189c174a4 +[NSAppearance _performWithCurrentAppearance:usingBlock:] + 72 (NSAppearance.m:2408)
508 SwiftUI                       	0x00000001b53b2088 specialized static NSColor.withColorAppearance(in:_:) + 324 (AppKitColorConversions.swift:142)
509 SwiftUI                       	0x00000001b53b1e7c protocol witness for ColorProvider.resolve(in:) in conformance NSColor + 68 (<compiler-generated>:151)
510 SwiftUICore                   	0x0000000222436e6c ColorBox.resolve(in:) + 124 (Color.swift:288)

Crash due to likely infinitely recursive call in SwiftUI &#96;Color.Resolved.init&#96;
 
 
Q