Crash while selecting data point in zoomed state
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).
## What did you do?
ℹ I zoomed the charts and made a selection to one of the data point.
## What did you expect to happen?
ℹ The delegate method with selected coordinates should be called.
## What happened instead?
ℹ Crash happed.
Crash log:
```
> * thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Double value cannot be converted to Int because it is either infinite or NaN
frame #0: 0x0000000116b4f900 libswiftCore.dylib`_swift_runtime_on_report
frame #1: 0x0000000116b90181 libswiftCore.dylib`_swift_stdlib_reportFatalError + 113
frame #2: 0x0000000116b2c38f libswiftCore.dylib`partial apply forwarder for closure #1 (Swift.UnsafeBufferPointer) -> () in closure #2 (Swift.UnsafeBufferPointer) -> () in Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 63
frame #3: 0x00000001168571eb libswiftCore.dylib`function signature specialization ) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer) -> ()]> of generic specialization of Swift.StaticString.withUTF8Buffer((Swift.UnsafeBufferPointer) -> A) -> A + 187
frame #4: 0x0000000116ae00f1 libswiftCore.dylib`partial apply forwarder for closure #2 (Swift.UnsafeBufferPointer) -> () in Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 113
frame #5: 0x00000001168571eb libswiftCore.dylib`function signature specialization ) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer) -> ()]> of generic specialization of Swift.StaticString.withUTF8Buffer((Swift.UnsafeBufferPointer) -> A) -> A + 187
frame #6: 0x0000000116a0b410 libswiftCore.dylib`function signature specialization of Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 96
* frame #7: 0x000000010ffccbea Charts`AxisRendererBase.computeAxisValues(min=NaN, max=NaN, self=0x0000600000e58630) at AxisRendererBase.swift:125
frame #8: 0x0000000110177e05 Charts`XAxisRenderer.computeAxisValues(min=NaN, max=NaN, self=0x0000600000e58630) at XAxisRenderer.swift:62
frame #9: 0x0000000110177d3e Charts`XAxisRenderer.computeAxis(min=0, max=2.02, inverted=false, self=0x0000600000e58630) at XAxisRenderer.swift:57
frame #10: 0x000000010fffe704 Charts`BarLineChartViewBase.notifyDataSetChanged(self=0x00007fe4bb579560) at BarLineChartViewBase.swift:332
frame #11: 0x000000011007618a Charts`ChartViewBase.data.setter(newValue=0x0000600000a900e0, self=0x00007fe4bb579560) at ChartViewBase.swift:269
frame #12: 0x000000010e6fc1d2 CittaDoctor.ai`GraphCell.drawGraph(values=3 values, isBPGraph=false, xArray=3 elements, minValue=0, maxValue=150, values2=3 values, graphColor=0x00006000012763c0, normalRange=(unit = "", maximum = 0, minimum = 0), optionArrays=CittaDoctor_ai.Options @ 0x00007ffee162c6f8, self=0x00007fe4bb5d5700) at GraphCell.swift:457
frame #13: 0x000000010e784423 CittaDoctor.ai`HistoryListingCV.collectionView(collectionView=0x00007fe4b6add000, indexPath=2 indices, self=0x00007fe4b6b16c00) at HistoryListingCV.swift:177
frame #14: 0x000000010e784bbc CittaDoctor.ai`@objc HistoryListingCV.collectionView(_:cellForItemAt:) at HistoryListingCV.swift:0
frame #15: 0x00000001127d48b6 UIKit`-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 290
```
## Charts Environment
**Charts version/Branch/Commit Number:3.0.4**
**Xcode version:9.2**
**Swift version:4**
**Platform(s) running Charts:iOS 11.3**
**macOS version running Xcode: 10.13.4**
## Demo Project
ℹ Please link to or upload a project we can download that reproduces the issue.
Contributor guide
Research direction
Start at AxisRendererBase.swift:125, then trace the NaN bounds through XAxisRenderer.swift and BarLineChartViewBase.swift:332. Reproduce the reported zoom-and-selection flow if possible; done means selection calls the delegate with coordinates without crashing during axis computation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- data-visualization, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100