With the release of a new version of our app we started to get this weird crash in Crashlytics:
Fatal Exception: NSRangeException
0 CoreFoundation 0x9e88 __exceptionPreprocess
1 libobjc.A.dylib 0x178d8 objc_exception_throw
2 Foundation 0x43590 -[NSConcreteAttributedString attributesAtIndex:effectiveRange:]
3 Foundation 0x26248 -[NSMutableAttributedString addAttributes:range:]
4 Foundation 0x26110 -[NSAttributedString enumerateAttributesInRange:options:usingBlock:]
5 Foundation 0x5717f0 -[NSAttributedString(NSAttributedStringFormattingSPI) __initWithFormat:attributeOptions:formattingOptions:locale:arguments:]
6 SwiftUI 0x4c30 -[CALayer(SwiftUIAdditions) setSwiftUI_displayListID:]
7 SwiftUI 0x7c08c copy_path_iter
8 SwiftUI 0xc5448 __swift_memcpy112_8
9 SwiftUI 0x60e70 OUTLINED_FUNCTION_244
10 SwiftUI 0x113c498 OUTLINED_FUNCTION_126
11 SwiftUI 0x120c02c OUTLINED_FUNCTION_3
12 SwiftUI 0x54ce20 objectdestroy.6496Tm
13 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
14 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
15 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
16 AttributeGraph 0x271c AGGraphGetValue
17 SwiftUI 0x4c92a8 OUTLINED_FUNCTION_1
18 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
19 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
20 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
21 AttributeGraph 0x271c AGGraphGetValue
22 SwiftUI 0x3f3b38 OUTLINED_FUNCTION_1
23 SwiftUI 0x4ae5ac OUTLINED_FUNCTION_1
24 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
25 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
26 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
27 AttributeGraph 0x271c AGGraphGetValue
28 SwiftUI 0x4ad338 OUTLINED_FUNCTION_1
29 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
30 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
31 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
32 AttributeGraph 0x7188 AGGraphGetInputValue
33 SwiftUI 0xfd2a30 OUTLINED_FUNCTION_14
34 SwiftUI 0x359624 OUTLINED_FUNCTION_1
35 SwiftUI 0x3589ac OUTLINED_FUNCTION_1
36 SwiftUI 0x4d44bc OUTLINED_FUNCTION_1
37 SwiftUI 0x4fde28 OUTLINED_FUNCTION_1
38 SwiftUI 0x35b734 OUTLINED_FUNCTION_1
39 SwiftUI 0x29b230 OUTLINED_FUNCTION_1
40 SwiftUI 0xd3198 OUTLINED_FUNCTION_133
41 SwiftUI 0x167050 __swift_memcpy7_4
42 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
43 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
44 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
45 AttributeGraph 0x7188 AGGraphGetInputValue
46 SwiftUI 0xfd2a30 OUTLINED_FUNCTION_14
47 SwiftUI 0x359624 OUTLINED_FUNCTION_1
48 SwiftUI 0x3589ac OUTLINED_FUNCTION_1
49 SwiftUI 0x4d4594 OUTLINED_FUNCTION_1
50 SwiftUI 0x35bb00 OUTLINED_FUNCTION_1
51 SwiftUI 0x29b2c0 OUTLINED_FUNCTION_1
52 SwiftUI 0xe0730 __swift_memcpy28_4
53 SwiftUI 0xdab64 -[TimeProvider .cxx_destruct]
54 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
55 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
56 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
57 AttributeGraph 0x7188 AGGraphGetInputValue
58 SwiftUI 0xfd2a30 OUTLINED_FUNCTION_14
59 SwiftUI 0x359624 OUTLINED_FUNCTION_1
60 SwiftUI 0x3589ac OUTLINED_FUNCTION_1
61 SwiftUI 0x4d44bc OUTLINED_FUNCTION_1
62 SwiftUI 0x4fde28 OUTLINED_FUNCTION_1
63 SwiftUI 0x35bb00 OUTLINED_FUNCTION_1
64 SwiftUI 0x29b2c0 OUTLINED_FUNCTION_1
65 SwiftUI 0xe0730 __swift_memcpy28_4
66 SwiftUI 0xd1600 OUTLINED_FUNCTION_626
67 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
68 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
69 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
70 AttributeGraph 0x7188 AGGraphGetInputValue
71 SwiftUI 0xfd2a30 OUTLINED_FUNCTION_14
72 SwiftUI 0x359624 OUTLINED_FUNCTION_1
73 SwiftUI 0x3589ac OUTLINED_FUNCTION_1
74 SwiftUI 0x4d4594 OUTLINED_FUNCTION_1
75 SwiftUI 0x35bb00 OUTLINED_FUNCTION_1
76 SwiftUI 0x29b2c0 OUTLINED_FUNCTION_1
77 SwiftUI 0xe0730 __swift_memcpy28_4
78 SwiftUI 0xdab64 -[TimeProvider .cxx_destruct]
79 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
80 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
81 AttributeGraph 0x4ff0 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
82 AttributeGraph 0x7188 AGGraphGetInputValue
83 SwiftUI 0x71790 OUTLINED_FUNCTION_112
84 SwiftUI 0x9a1f1c OUTLINED_FUNCTION_1
85 SwiftUI 0x9a2110 OUTLINED_FUNCTION_1
86 SwiftUI 0x9aeaf4 OUTLINED_FUNCTION_8
87 SwiftUI 0x9ae9cc OUTLINED_FUNCTION_8
88 SwiftUI 0x10c6cc8 OUTLINED_FUNCTION_61
89 SwiftUI 0xdeed4 -[TimeProvider .cxx_destruct]
90 SwiftUI 0x132ea2c OUTLINED_FUNCTION_44
91 SwiftUI 0x132e3c0 OUTLINED_FUNCTION_44
92 SwiftUI 0xb50b40 OUTLINED_FUNCTION_77
93 SwiftUI 0x10c6cc8 OUTLINED_FUNCTION_61
94 SwiftUI 0xdeed4 -[TimeProvider .cxx_destruct]
95 SwiftUI 0x132ea2c OUTLINED_FUNCTION_44
96 SwiftUI 0x132e3c0 OUTLINED_FUNCTION_44
97 SwiftUI 0xb50b40 OUTLINED_FUNCTION_77
98 SwiftUI 0x10c6cc8 OUTLINED_FUNCTION_61
99 SwiftUI 0xe4b224 OUTLINED_FUNCTION_0
100 SwiftUI 0xb5109c OUTLINED_FUNCTION_77
101 SwiftUI 0xb50de4 OUTLINED_FUNCTION_77
102 SwiftUI 0x10c6de8 OUTLINED_FUNCTION_61
103 SwiftUI 0x8e714 OUTLINED_FUNCTION_134
104 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
105 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
106 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
107 AttributeGraph 0x271c AGGraphGetValue
108 SwiftUI 0x7229c OUTLINED_FUNCTION_71
109 SwiftUI 0xf7ae0 OUTLINED_FUNCTION_1125
110 SwiftUI 0x861d8 OUTLINED_FUNCTION_120
111 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
112 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
113 AttributeGraph 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
114 AttributeGraph 0x271c AGGraphGetValue
115 SwiftUI 0xa86a0 __swift_memcpy40_8
116 SwiftUI 0xe86dc OUTLINED_FUNCTION_242
117 AttributeGraph 0x46f4 AG::Graph::UpdateStack::update()
118 AttributeGraph 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
119 AttributeGraph 0x2c00 AG::Subgraph::update(unsigned int)
120 SwiftUI 0x1df28 OUTLINED_FUNCTION_29
121 SwiftUI 0x13e1350 OUTLINED_FUNCTION_26
122 SwiftUI 0x9d82ac OUTLINED_FUNCTION_1
123 SwiftUI 0x1b58c OUTLINED_FUNCTION_69
124 SwiftUI 0x1504c OUTLINED_FUNCTION_216
125 SwiftUI 0xea68 _setThreadGeometryProxyData
126 SwiftUI 0x13e1318 OUTLINED_FUNCTION_26
127 SwiftUI 0x13e1204 OUTLINED_FUNCTION_26
128 SwiftUI 0xe8e30 OUTLINED_FUNCTION_242
129 SwiftUI 0xc1a4 OUTLINED_FUNCTION_8
130 SwiftUI 0xc0d4 OUTLINED_FUNCTION_10
131 SwiftUI 0xc368 OUTLINED_FUNCTION_27
132 CoreFoundation 0x91d60 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
133 CoreFoundation 0x1a2d0 __CFRunLoopDoObservers
134 CoreFoundation 0x7bc7c __CFRunLoopRun
135 CoreFoundation 0x80ed4 CFRunLoopRunSpecific
136 GraphicsServices 0x1368 GSEventRunModal
137 UIKitCore 0x3a23d0 -[UIApplication _run]
138 UIKitCore 0x3a2034 UIApplicationMain
139 libswiftUIKit.dylib 0x35308 UIApplicationMain(_:_:_:_:)
140 StackoverflowAppName 0xe0f8c main (AppDelegate.swift)
141 ??? 0x1e73d4960 (Missing)
I personally cannot reproduce it so my input is limited, but from the breadcrumbs on Crashlytics it seems as though it happens during two separate flows but it might just be the case that something in the background is causing an update.
We’re currently deploying to iOS 15.6+ and we use a mix of SwiftUI and UIKit in the app. We definitely also have some NSAttributedString
and AttributedString
manipulations but I’d imagine the stacktrace would then display the offending calling function and yet all I see is a vague call initiated from the AppDelegate.
I mainly tried adding logs and following different logs with different permutations of the app but nothing seems to even reproduce it. This is so vague I am not even sure where to start. I am considering swizzling NSAttributedString
methods and logging the string value from there.