Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Double value cannot be converted to Int because it is either infinite or NaN - in AxisRendererBase #3352

Closed
Saranjithpk opened this issue Mar 20, 2018 · 5 comments
Labels

Comments

@Saranjithpk
Copy link

What did you do?

Rare dataset inputs passed to draw.

What did you expect to happen?

Library should manage such case.

What happened instead?

Application is crashed.

Stack Trace:

* 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: 0x00000001035e8df0 libswiftCore.dylib`_swift_runtime_on_report
    frame #1: 0x00000001036247c8 libswiftCore.dylib`_swift_stdlib_reportFatalError + 116
    frame #2: 0x000000010333e98c libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer<A>((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A + 72
    frame #3: 0x000000010333e98c libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer<A>((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A + 72
    frame #4: 0x00000001034cf1ac libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 120
  * frame #5: 0x00000001025ecb48 Charts`AxisRendererBase.computeAxisValues(min=NaN, max=NaN, self=0x00000001c1e5f260) at AxisRendererBase.swift:125
    frame #6: 0x000000010275a588 Charts`XAxisRenderer.computeAxisValues(min=NaN, max=NaN, self=0x00000001c1e5f260) at XAxisRenderer.swift:62
    frame #7: 0x000000010275a4b8 Charts`XAxisRenderer.computeAxis(min=0, max=2.02, inverted=false, self=0x00000001c1e5f260) at XAxisRenderer.swift:57
    frame #8: 0x00000001026166c0 Charts`BarLineChartViewBase.notifyDataSetChanged(self=0x000000011c5ae620) at BarLineChartViewBase.swift:332
    frame #9: 0x0000000102682164 Charts`ChartViewBase.data.setter(newValue=0x00000001c1481860, self=0x000000011c5ae620) at ChartViewBase.swift:269
    frame #10: 0x000000010146d5b0 PersonalCare`GraphCell.drawGraph(values=3 values, isBPGraph=false, xArray=3 elements, minValue=0, maxValue=146, values2=0 values, graphColor=0x00000001c2071e00, normalRange=(unit = "mg/dl", maximum = 108, minimum = 70), optionArrays=PersonalCare.Options @ 0x000000016edff5d0, self=0x000000011c5adf30) at GraphCell.swift:420
    frame #11: 0x0000000101387874 PersonalCare`HistoryDetailViewController.collectionView(collectionView=0x0000000118ac6e00, indexPath=2 indices, self=0x000000011a15ce00) at HistoryDetailViewController.swift:919
    frame #12: 0x00000001013897b0 PersonalCare`@objc HistoryDetailViewController.collectionView(_:cellForItemAt:) at HistoryDetailViewController.swift:0
    frame #13: 0x000000018d47fac8 UIKit`-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 312
    frame #14: 0x000000018ca6f344 UIKit`-[UICollectionView _updateVisibleCellsNow:] + 3820
    frame #15: 0x000000018ca6a02c UIKit`-[UICollectionView layoutSubviews] + 356
    frame #16: 0x000000018ca0d000 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1256
    frame #17: 0x00000001875dd0b4 QuartzCore`-[CALayer layoutSublayers] + 184
    frame #18: 0x00000001875e1194 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 332
    frame #19: 0x000000018754ff24 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 336
    frame #20: 0x0000000187576340 QuartzCore`CA::Transaction::commit() + 540
    frame #21: 0x0000000187577180 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
    frame #22: 0x00000001835a78b8 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
    frame #23: 0x00000001835a5270 CoreFoundation`__CFRunLoopDoObservers + 412
    frame #24: 0x00000001835a582c CoreFoundation`__CFRunLoopRun + 1292
    frame #25: 0x00000001834c62d8 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #26: 0x0000000185357f84 GraphicsServices`GSEventRunModal + 100
    frame #27: 0x000000018ca73880 UIKit`UIApplicationMain + 208
    frame #28: 0x00000001013b1adc PersonalCare`main at AppDelegate.swift:18
    frame #29: 0x0000000182fea56c libdyld.dylib`start + 4

Charts Environment

Charts version/Branch/Commit Number:3.0.4
Xcode version:9.2
Swift version:4.1
Platform(s) running Charts: iOS: 11.0.3
macOS version running Xcode: High Sierra version: 10.13.3

Demo Project

Rare case in working project. Whole project can't be included here.

@liuxuan30
Copy link
Member

you should check why computeAxisValues(min=NaN, max=NaN in the first place.

@liuxuan30
Copy link
Member

@jjatie @petester42 @danielgindi I asked one issue github-changelog-generator/github-changelog-generator#632 to avoid letting changelog generator includes closed issues that are just questions.
we could start tagging issues to avoid this.
by default it will exclude 'duplicate,question,invalid, wontfix'

@atalayasa
Copy link

I've faced same issue too and I solved it adding range.isNaN control at the AxisRenderBase.swift file 98th line should look like this if labelCount == 0 || range <= 0 || range.isInfinite || range.isNaN

@liuxuan30
Copy link
Member

as I said, why it's NaN is top priority. Adding checks only prevent from crash, but the chart will be wrong

@atalayasa
Copy link

How can I discover why it is NaN and which is NaN x values or y values? @liuxuan30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants