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

Crash after updating to iOS 13.6 and Xcode 11.6 on NaN #4433

Closed
HollyWallace opened this issue Jul 31, 2020 · 1 comment
Closed

Crash after updating to iOS 13.6 and Xcode 11.6 on NaN #4433

HollyWallace opened this issue Jul 31, 2020 · 1 comment

Comments

@HollyWallace
Copy link

Hi - thank you for the wonderful Charts app.

I have three scatter plots on a view controller, in this case each with only one dot. I removed the data so the charts were empty, then tried to select another set of data. By then, it had already crashed. The difference is that I had updated my Mac OS, my iPad iOS and my Xcode version.

What did you expect to happen?

No crash.

What happened instead?

Crash

Charts Environment

Charts 3.4.0
Xcode 11.6
Swift 5.2
iPad mini running iOS 13.6
development machine running OS 10.15.6

Here are the errors:
The indicator pointed to line 119 in Pod/Pods/Charts/Core/AxisRendererBase.swift computeAxisValues(min:max:)

Fatal error: Double value cannot be converted to Int because it is either infinite or NaN: file /Library/Caches/com.apple.xbs/Binaries/SwiftPrebuiltSDKModules_iOS/install/TempContent/Objects/EmbeddedProjects/CrossTrain_iOS_SDK/iOS_SDK/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/swift/Swift.swiftmodule/arm64.swiftinterface, line 28468

In this function:

/// Sets up the axis values. Computes the desired number of labels between the two given extremes.
@objc open func computeAxisValues(min: Double, max: Double)
{
guard let axis = self.axis else { return }

    let yMin = min
    let yMax = max
    
    let labelCount = axis.labelCount
    let range = abs(yMax - yMin)
    
    if labelCount == 0 || range <= 0 || range.isInfinite
    {
        axis.entries = [Double]()
        axis.centeredEntries = [Double]()
        return
    }
    
    // Find out how much spacing (in y value space) between axis values
    let rawInterval = range / Double(labelCount)
    var interval = rawInterval.roundedToNextSignficant()
    
    // If granularity is enabled, then do not allow the interval to go below specified granularity.
    // This is used to avoid repeated values when rounding values for display.
    if axis.granularityEnabled
    {
        interval = interval < axis.granularity ? axis.granularity : interval
    }
    
    // Normalize interval
    let intervalMagnitude = pow(10.0, Double(Int(log10(interval)))).roundedToNextSignficant()         <--- The line just above here crashes
    let intervalSigDigit = Int(interval / intervalMagnitude)

    etc.

In the debugger:

min = (Double) NaN
max = (Double) NaN
interval = (Double) NaN
n = (Int) 0
yMin = (Double) NaN
yMax = (Double) NaN
labelCount = (Int) 6
range = (Double) NaN
rawInterval = (Double) NaN
intervalMagnitude (Double)
intervalSigDigit (Int)

self = (Charts.YAxisRenderer) long number
axis = (Charts.YAxis) long number and lots of sub categories

The first thing I did after all the upgrades was to go into my development app to see if I had successfully managed to prevent all gestures from affecting the charts. Nope - they still move, but in this case, for the first time ever, they also crashed. Hope this helps.

@HollyWallace
Copy link
Author

I just tried to edit my post and can't so the line in the code that says "<--- the line just above here crashes" is actually pointing straight at the line that crashed. The variable "interval" is NaN when it arrived at that line.

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

No branches or pull requests

1 participant