ios - SwiftUI 因一位用户的 EXC_BREAKPOINT (SIGTRAP) 而崩溃,我无法在模拟器中复制它
问题描述
今年我自学了编码,终于开始通过 TestFlight 与一些朋友分享我的应用程序。我的一位朋友无法在应用程序中点击任何内容而不会崩溃,但我似乎无法在模拟器中复制该问题。这是崩溃日志:
Incident Identifier: 9C5CBC92-D799-4EF7-A0BD-B3D38BDFCD6A
Beta Identifier: 14981E01-C6E4-4340-A6C2-2C7730C5F39F
Hardware Model: iPhone9,3
Process: Skool [849]
Path: /private/var/containers/Bundle/Application/CD824E3B-BB88-47D1-912E-55156C40187E/Skool.app/Skool
Identifier: com.kevinolmats.Skool
Version: 2777 (0.2.2)
AppStoreTools: 11E503a
AppVariant: 1:iPhone9,3:13
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.kevinolmats.Skool [677]
Date/Time: 2020-05-09 10:19:43.2873 -0600
Launch Time: 2020-05-09 10:19:41.3463 -0600
OS Version: iPhone OS 13.4.1 (17E262)
Release Type: User
Baseband Version: 4.02.02
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001becb85e0
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [849]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libswiftCore.dylib 0x00000001becb85e0 _assertionFailure(_:_:file:line:flags:) + 796 (AssertCommon.swift:132)
1 libswiftCore.dylib 0x00000001becb85e0 _assertionFailure(_:_:file:line:flags:) + 796 (AssertCommon.swift:132)
2 SwiftUI 0x00000001e9394268 EnvironmentObject.error() + 216 (EnvironmentObject.swift:55)
3 Skool 0x0000000104223228 CourseAssignmentsListView.body.getter + 2116 (CourseAssignmentsListView.swift:0)
4 SwiftUI 0x00000001e8ef4a40 DynamicPropertyBody.update(context:) + 1788 (CustomView.swift:110)
5 SwiftUI 0x00000001e8ef5040 protocol witness for static UntypedAttribute._update(_:graph:attribute:) in conformance DynamicPr... + 36 (<compiler-generated>:0)
6 AttributeGraph 0x00000001dd21e998 partial apply + 28 (<compiler-generated>:0)
7 AttributeGraph 0x00000001dd2079fc AG::Graph::UpdateStack::update() + 440 (ag-closure.h:104)
8 AttributeGraph 0x00000001dd207eb4 AG::Graph::update_attribute(unsigned int, bool) + 372 (ag-graph-update.cc:399)
9 AttributeGraph 0x00000001dd20b044 AG::Graph::value_ref(AG::attribute_t, AGTypeID, bool*) + 116 (ag-graph.cc:762)
10 AttributeGraph 0x00000001dd218310 AGGraphGetValue + 48 (AGGraph.mm:304)
11 SwiftUI 0x00000001e8ff59a0 ViewGraph.accessibilityNodes() + 108 (<compiler-generated>:0)
12 SwiftUI 0x00000001e93adf08 specialized _UIHostingView.enableAccessibility() + 116
13 SwiftUI 0x00000001e93a4aac specialized _UIHostingView.init(rootView:) + 2116 (UIHostingView.swift:1278)
14 SwiftUI 0x00000001e93b3dc8 specialized UIHostingController.init(rootView:) + 56 (UIHostingView.swift:0)
15 SwiftUI 0x00000001e933df74 specialized DestinationHostingController.__allocating_init(rootView:) + 56 (<compiler-generated>:0)
16 SwiftUI 0x00000001e933dd2c NavigationBridge_PhoneTV.push(_:onto:animated:) + 76 (NavigationBridge_PhoneTV.swift:84)
17 SwiftUI 0x00000001e8f83438 UIKitNavigationBridge.updatePresentedContent(_:animated:) + 204 (UIKitNavigationBridge.swift:168)
18 SwiftUI 0x00000001e8f83844 UIKitNavigationBridge.preferencesDidChange(_:) + 372 (UIKitNavigationBridge.swift:203)
19 SwiftUI 0x00000001e933d560 NavigationBridge_PhoneTV.preferencesDidChange(_:) + 44 (NavigationBridge_PhoneTV.swift:21)
20 SwiftUI 0x00000001e8f26078 _UIHostingView.preferencesDidChange() + 476 (_UIHostingView.swift:199)
21 SwiftUI 0x00000001e8ff3d74 ViewGraph.updateOutputs(at:) + 180 (ViewGraph.swift:652)
22 SwiftUI 0x00000001e92928b4 closure #1 in closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 816 (ViewRendererHost.swift:157)
23 SwiftUI 0x00000001e9291d54 closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 524 (ViewRendererHost.swift:145)
24 SwiftUI 0x00000001e9288c5c ViewRendererHost.render(interval:updateDisplayList:) + 316 (ViewRendererHost.swift:132)
25 SwiftUI 0x00000001e93aee50 _UIHostingView.displayLinkTimer(timestamp:) + 160 (UIHostingView.swift:1391)
26 SwiftUI 0x00000001e8f26344 DisplayLink.displayLinkTimer(_:) + 88 (_UIHostingView.swift:270)
27 SwiftUI 0x00000001e8f2639c @objc DisplayLink.displayLinkTimer(_:) + 40 (<compiler-generated>:0)
28 QuartzCore 0x00000001b81c0368 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 516 (CADisplay.mm:2528)
29 IOKit 0x00000001b2751628 IODispatchCalloutFromCFMessage + 480 (IOKitLib.c:1239)
30 CoreFoundation 0x00000001b1762bc0 __CFMachPortPerform + 172 (CFMachPort.c:533)
31 CoreFoundation 0x00000001b178c200 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 (CFRunLoop.c:1937)
32 CoreFoundation 0x00000001b178b90c __CFRunLoopDoSource1 + 444 (CFRunLoop.c:2075)
33 CoreFoundation 0x00000001b17866c0 __CFRunLoopRun + 1888 (CFRunLoop.c:3098)
34 CoreFoundation 0x00000001b1785c34 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
35 GraphicsServices 0x00000001bb8cf38c GSEventRunModal + 160 (GSEvent.c:2246)
36 UIKitCore 0x00000001b58b822c UIApplicationMain + 1932 (UIApplication.m:4820)
37 Skool 0x000000010417275c main + 68 (OverdueDashboardSubview.swift:13)
38 libdyld.dylib 0x00000001b160d800 start + 4
Thread 1:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x00000001b15e1198 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001b15e060c mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x00000001b178b3b4 __CFRunLoopServiceMachPort + 148 (CFRunLoop.c:2575)
3 CoreFoundation 0x00000001b17863e8 __CFRunLoopRun + 1160 (CFRunLoop.c:2931)
4 CoreFoundation 0x00000001b1785c34 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
5 Foundation 0x00000001b1ac8bcc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:374)
6 Foundation 0x00000001b1ac8aac -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:421)
7 UIKitCore 0x00000001b595a160 -[UIEventFetcher threadMain] + 152 (UIEventFetcher.m:736)
8 Foundation 0x00000001b1bf79d0 __NSThread__start__ + 848 (NSThread.m:724)
9 libsystem_pthread.dylib 0x00000001b1523d98 _pthread_start + 156 (pthread.c:896)
10 libsystem_pthread.dylib 0x00000001b152774c thread_start + 8
Thread 7:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 8:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 9:
0 libsystem_pthread.dylib 0x00000001b1527738 start_wqthread + 0
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000105d669e0 x1: 0x00000001bef56ef8 x2: 0x0000000000000407 x3: 0x000000000000001e
x4: 0x0000000105d71c00 x5: 0x0000000000000013 x6: 0x0000000000000000 x7: 0x00000000000003f8
x8: 0x0000000105d669e8 x9: 0x0000000200000002 x10: 0xfffffffe00000000 x11: 0x0000000000000000
x12: 0x0000000000000002 x13: 0x0000000000003fff x14: 0x000000004ca45cf5 x15: 0x000000000000f0be
x16: 0x00000001b1512ffc x17: 0x0000000001000002 x18: 0x0000000000000000 x19: 0x0000000105d669e0
x20: 0x0000000000000000 x21: 0x0000000000000000 x22: 0x0000000000000000 x23: 0x00000001e94156a0
x24: 0x0000000105d669e0 x25: 0xf000000000000095 x26: 0x000000000000000b x27: 0x0000000000000002
x28: 0x00000001042c7c58 fp: 0x000000016bc906a0 lr: 0x00000001becb85e0
sp: 0x000000016bc90620 pc: 0x00000001becb85e0 cpsr: 0x60000000
esr: 0xf2000001 Address size fault
我特别关心这一行:
37 Skool 0x000000010417275c main + 68 (OverdueDashboardSubview.swift:13)
在代码中,该行是:
@FetchRequest(entity: Assignment.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Assignment.dueDate, ascending: true), NSSortDescriptor(keyPath: \Assignment.name, ascending: true)]) var assignments: FetchedResults<Assignment>
但这对我和我发送测试版的其他所有人来说都很好。崩溃日志中是否缺少某些内容?就像我说的那样,我对编码很陌生,在阅读这样的日志时甚至更新。任何想法将不胜感激!
编辑:这是 CourseAssignmentListView 要求的代码:
struct CourseAssignmentsListView: View {
@FetchRequest(entity: Assignment.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \Assignment.course?.name, ascending: true),
NSSortDescriptor(keyPath: \Assignment.isDue, ascending: false),
NSSortDescriptor(keyPath: \Assignment.dueDate, ascending: true),
NSSortDescriptor(keyPath: \Assignment.name, ascending: true)]) var assignments: FetchedResults<Assignment>
@EnvironmentObject var accentColor: AccentColorManager
@Environment(\.managedObjectContext) var context
@State var course: Course?
@State private var newAssignment: Assignment? = nil
@State var newAssignmentViewIsPresented = false
var body: some View {
Group {
if self.assignments.filter({ $0.course?.name == self.course?.name }).isEmpty {
Text("No Assignments")
.foregroundColor(.secondary)
.font(.largeTitle)
} else {
List(assignments.filter { $0.course?.name == self.course?.name }, id: \.self) { assignment in
AssignmentRow(assignment: assignment).environment(\.managedObjectContext, self.context)
}
}
}
.navigationBarTitle(Text("\(course?.wrappedName ?? "")").foregroundColor(course?.color ?? Color.primary))
.navigationBarItems(
trailing: Button(
action: {
self.newAssignment = Assignment(context: self.context)
self.newAssignmentViewIsPresented = true
}
) {
Image(systemName: "plus")
.accessibility(label: Text("New Assignment"))
.font(.title)
})
.accentColor(self.accentColor.color)
.onAppear {
self.accentColor.color = self.course?.color ?? .green
}
.sheet(isPresented: $newAssignmentViewIsPresented, content: {
AssignmentEditorView(assignment: self.newAssignment!, defaultCourse: self.course).environment(\.managedObjectContext, self.context)
})
}
}
解决方案
我看到了几乎相同的崩溃。SwiftUI 似乎仍然存在一个错误,即@EnvironmentObject
在子视图中无法访问变量。
您是从NavigationLink(在NavigationView或List中)还是在模式表中启动CourseAssignmentsListView ?如果是这样,请尝试使用修饰符直接注入您的AccentColorManager - 如下所示:.environmentObject
// In the parent view
@EnvironmentObject var accentColor: AccentColorManager
// Wherever you are loading the view from... demonstrating using `NavigationLink`
NavigationLink(CourseAssignmentsListView().environmentObject(self.accentColor))
就我而言,我们刚刚让两个有崩溃的人都报告说这种方法有效。
推荐阅读
- odata - 如何从 Odata Service SAP ui5 读取聚合实体
- api - 在没有文档的情况下查找可查询变量
- reactjs - Reactjs - @influxdata/giraffe - 表格图未呈现
- chronicle - ChronicleWire 是否支持实体中的可选字段?
- c# - C# List 添加了不正确的成员
- vue.js - 如果它们是字符串 vue 中的类型,则不包括 tailwind css 类
- python-3.x - 属性错误:pickle.load() Seldon 部署
- html - 我正在创建一个带有垂直文本的 HTML 表格,但我无法调整宽度以最小化空白空间
- ruby - 为什么线程中分叉进程的存在会改变陷阱块内的睡眠行为?
- javascript - 仅在电子应用程序窗口处于焦点时按下特定键时在电子中创建一个新窗口?