Hi,
One tester has faced the below crash when leaving a screen that has a progress bar item, apparently the geometry.size.width check is where it crashed but I don't understand why could that line cause it or if I could add some check to avoid it. The error can't be reproduced in the tester's device or any other, it looks like an issolated crash probably due to some internal swiftui thing that I can't figure out.
The app pages are inside an UITabBarController.
//
// ProgressBarItem.swift
// Sellispace
//
// Created by Marc Biosca on 5/4/20.
// Copyright © 2020 Marc Biosca. All rights reserved.
//
import SwiftUI
struct ProgressBarItem: View {
@ObservedObject var model: WebViewObservable
let uuid: String
var body: some View {
GeometryReader { geometry in
VStack {
ZStack(alignment: .trailing) {
ZStack (alignment: .leading) {
Rectangle()
.frame(width: geometry.size.width)
.foregroundColor(ThemeColors.accentColor)
.opacity(0.5)
ZStack (alignment: .trailing) {
Rectangle()
.frame(width: geometry.size.width * CGFloat(self.model.estimatedProgress))
.foregroundColor(self.model.errorTriggered ? ThemeColors.errorCancelColor : self.model.estimatedProgress > 0.9 ? ThemeColors.OkColor : ThemeColors.alternativeAccentColor)
Image("Selli_intro")
.fit()
.padding(.trailing, self.model.estimatedProgress > 0.9 ? 25 : 5)
.padding(.leading, self.model.estimatedProgress < 0.2 ? 5 : 5)
.padding(.vertical, 1)
}
HStack {
Spacer()
Text("\(StringValues.loaded)\((self.model.estimatedProgress * 100).format(decimals: self.model.estimatedProgress == 1 ? "0" : "2"))%")
.comment(foregroundColor: Color.white)
Spacer()
}
.animation(.none)
}
.cornerRadius(5)
Button(action: {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refresh-\(self.uuid)"), object: nil)
}) {
Image(systemName: "arrow.clockwise")
.fit()
.padding(.vertical, 3)
.padding(.trailing, 5)
.foregroundColor(Color.white)
}
}
}
}
.padding(5)
}
}
struct ProgressBarItem_Preview: PreviewProvider {
static var previews: some View {
NavigationView {
ProgressBarItem(model: WebViewObservable(), uuid: "test")
.navigationBarTitle("Preview", displayMode: .inline)
}
//.environment(\.colorScheme, .dark)
}
}
Crash:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001abbf5d88 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001abb0e1e8 pthread_kill$VARIANT$mp + 136 (pthread.c:1458)
2 libsystem_c.dylib 0x00000001aba61644 abort + 100 (abort.c:110)
3 AttributeGraph 0x00000001d740bd90 AG::precondition_failure(char const*, ...) + 188 (ag-util.cc:38)
4 AttributeGraph 0x00000001d73e2540 AG::Graph::input_value_ref_slow(unsigned int, unsigned int, AGTypeID, bool*) + 476 (ag-graph.cc:842)
5 SwiftUI 0x00000001e2b0877c RootGeometry.update(context:) + 112 (<compiler-generated>:0)
6 SwiftUI 0x00000001e2b0c220 partial apply for protocol witness for static UntypedAttribute._update(_:graph:attribute:) in con... + 24 (<compiler-generated>:0)
7 AttributeGraph 0x00000001d73de9fc AG::Graph::UpdateStack::update() + 440 (ag-closure.h:104)
8 AttributeGraph 0x00000001d73deeb4 AG::Graph::update_attribute(unsigned int, bool) + 372 (ag-graph-update.cc:399)
9 AttributeGraph 0x00000001d73e2438 AG::Graph::input_value_ref_slow(unsigned int, unsigned int, AGTypeID, bool*) + 212 (ag-graph.cc:866)
10 SwiftUI 0x00000001e2b95518 _PositionAwareLayoutContext.dimensions.getter + 56 (<compiler-generated>:0)
11 SwiftUI 0x00000001e2c15418 partial apply for thunk for @callee_guaranteed () -> (@unowned CGSize) + 24 (<compiler-generated>:0)
12 SwiftUI 0x00000001e2c15834 specialized closure #1 in GeometryProxy.sync<A>(_:) + 92 (GeometryReader.swift:126)
13 SwiftUI 0x00000001e2c15dac specialized closure #1 in GeometryProxy.sync<A>(_:) + 20 (<compiler-generated>:0)
14 SwiftUI 0x00000001e2d9a49c ViewRendererHost.updateViewGraph<A>(body:) + 80 (ViewRendererHost.swift:70)
15 SwiftUI 0x00000001e2c149c8 GeometryProxy.size.getter + 176 (GeometryReader.swift:125)
16 Sellispace 0x0000000102689cd4 closure #1 in closure #1 in closure #1 in closure #1 in ProgressBarItem.body.getter + 68 (ProgressBarItem.swift:21)
17 Sellispace 0x00000001026899b0 closure #1 in closure #1 in closure #1 in ProgressBarItem.body.getter + 448 (ProgressBarItem.swift:0)
18 Sellispace 0x0000000102689744 closure #1 in ProgressBarItem.body.getter + 400 (<compiler-generated>:0)
19 Sellispace 0x000000010268a8e8 partial apply for closure #1 in ProgressBarItem.body.getter + 20 (<compiler-generated>:0)
20 SwiftUI 0x00000001e2c1515c GeometryReader.Child.update(context:) + 396 (GeometryReader.swift:79)
21 SwiftUI 0x00000001e2c153b4 protocol witness for static UntypedAttribute._update(_:graph:attribute:) in conformance GeometryR... + 36 (<compiler-generated>:0)
22 AttributeGraph 0x00000001d73f5998 partial apply + 28 (<compiler-generated>:0)
23 AttributeGraph 0x00000001d73de9fc AG::Graph::UpdateStack::update() + 440 (ag-closure.h:104)
24 AttributeGraph 0x00000001d73deeb4 AG::Graph::update_attribute(unsigned int, bool) + 372 (ag-graph-update.cc:399)
25 AttributeGraph 0x00000001d73e3c30 AG::Subgraph::update(unsigned int) + 688 (ag-subgraph.cc:517)
26 SwiftUI 0x00000001e2b05c84 ViewGraph.runTransaction(in:) + 212 (ViewGraph.swift:716)
27 SwiftUI 0x00000001e2b05a48 closure #1 in ViewGraph.flushTransactions() + 252 (ViewGraph.swift:612)
28 SwiftUI 0x00000001e2b056ec ViewGraph.flushTransactions() + 180 (<compiler-generated>:0)
29 SwiftUI 0x00000001e2da3c24 closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 220 (ViewRendererHost.swift:140)
30 SwiftUI 0x00000001e2d9ac5c ViewRendererHost.render(interval:updateDisplayList:) + 316 (ViewRendererHost.swift:132)
31 SwiftUI 0x00000001e2ec0d78 _UIHostingView.layoutSubviews() + 160 (UIHostingView.swift:1377)
32 SwiftUI 0x00000001e2ec0da4 @objc _UIHostingView.layoutSubviews() + 24 (<compiler-generated>:0)
33 UIKitCore 0x00000001b0359c7c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2144 (UIView.m:17176)
34 QuartzCore 0x00000001b28f34ac -[CALayer layoutSublayers] + 284 (CALayer.mm:9644)
35 QuartzCore 0x00000001b28f9604 CA::Layer::layout_if_needed(CA::Transaction*) + 468 (CALayer.mm:9518)
36 QuartzCore 0x00000001b2904148 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140 (CALayer.mm:2468)
37 QuartzCore 0x00000001b284ce34 CA::Context::commit_transaction(CA::Transaction*, double) + 296 (CAContextInternal.mm:1992)
38 QuartzCore 0x00000001b28767c4 CA::Transaction::commit() + 676 (CATransactionInternal.mm:438)
39 QuartzCore 0x00000001b28771d8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92 (CATransactionInternal.mm:890)
40 CoreFoundation 0x00000001abd7dfb8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1758)
41 CoreFoundation 0x00000001abd78eac __CFRunLoopDoObservers + 420 (CFRunLoop.c:1868)
42 CoreFoundation 0x00000001abd79328 __CFRunLoopRun + 968 (CFRunLoop.c:2910)
43 CoreFoundation 0x00000001abd78c34 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
44 GraphicsServices 0x00000001b5ec238c GSEventRunModal + 160 (GSEvent.c:2246)
45 UIKitCore 0x00000001afeab22c UIApplicationMain + 1932 (UIApplication.m:4820)
46 Sellispace 0x000000010262d680 main + 68 (CoreManager.swift:15)
47 libdyld.dylib 0x00000001abc00800 start + 4