Closed hiragram closed 10 months ago
Describe the bug Test crashes view.layer.render(in: ctx.cgContext) when view contains Swift Charts
To Reproduce Minimum reproduction code is TBD.
:x: Crashed
Chart(data ?? [], id: \.date) { entry in AreaMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) .foregroundStyle(.linearGradient(.init(colors: [.key.opacity(0.4), .key.opacity(0.05)]), startPoint: .top, endPoint: .bottom)) .interpolationMethod(interpolationMethod) LineMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) .lineStyle(.init(lineWidth: 2)) .foregroundStyle(Color.key) .symbol { Circle() .foregroundColor(.key) .frame(width: 8) .overlay { Circle() .padding(2) .foregroundColor(.background) } } .interpolationMethod(interpolationMethod) } .frame(height: 200) .chartXAxis(.visible) .chartYAxis(.visible) .chartYScale(domain: 0 ... yAxisMax) .chartXAxis { AxisMarks(values: .stride(by: .day)) { value in if value.index % (value.count / 3) == 0 { AxisGridLine() AxisValueLabel() } else { AxisGridLine() } } } .chartOverlay { chartProxy in GeometryReader { geometry in Rectangle().fill(.clear).contentShape(Rectangle()) .gesture( DragGesture(minimumDistance: 0) .onChanged({ value in let currentX = value.location.x - geometry[chartProxy.plotAreaFrame].origin.x if let currentDate: Date = chartProxy.value(atX: currentX) { presenter.setSelectedDate(date: currentDate) } }) ) } }
:x: Crashed even if all modifiers of Chart are removed
Chart
Chart(data ?? [], id: \.date) { entry in AreaMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) .foregroundStyle(.linearGradient(.init(colors: [.key.opacity(0.4), .key.opacity(0.05)]), startPoint: .top, endPoint: .bottom)) .interpolationMethod(interpolationMethod) LineMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) .lineStyle(.init(lineWidth: 2)) .foregroundStyle(Color.key) .symbol { Circle() .foregroundColor(.key) .frame(width: 8) .overlay { Circle() .padding(2) .foregroundColor(.background) } } .interpolationMethod(interpolationMethod) }
:x: Crashed even if all modifiers of XXXMarks are removed.
XXXMark
Chart(data ?? [], id: \.date) { entry in AreaMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) LineMark( x: .value("Date", entry.date), y: .value("Count", entry.count) ) }
✅ Did not crash if Chart contains no XXXMark
Chart(data ?? [], id: \.date) { entry in }
Expected behavior No crash
Environment
d1082c48edaee17914556517b29cea7e3388b2b7
Additional context Add any more context about the problem here.
Hi @hiragram, I am going to convert this to a discussion because it is not clear that it is actually a problem with the library that we could possible fix. It seems to be a problem with the Charts framework.
Describe the bug Test crashes view.layer.render(in: ctx.cgContext) when view contains Swift Charts
To Reproduce Minimum reproduction code is TBD.
:x: Crashed
:x: Crashed even if all modifiers of
Chart
are removed:x: Crashed even if all modifiers of
XXXMark
s are removed.✅ Did not crash if
Chart
contains noXXXMark
Expected behavior No crash
Environment
d1082c48edaee17914556517b29cea7e3388b2b7
)Additional context Add any more context about the problem here.