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 on zoom #931

Closed
calkinssean opened this issue Apr 8, 2016 · 9 comments
Closed

Crash on zoom #931

calkinssean opened this issue Apr 8, 2016 · 9 comments
Labels

Comments

@calkinssean
Copy link

Hi, if I zoom in too fast and far my app crashes. The error I am getting is fatal error: stride must not be zero. I noticed on your demo apps there seems to be a max zoom which eliminates this crash. I am wondering how I can implement this.

@liuxuan30
Copy link
Member

please paste the stack trace when crashing. It's better if we know how to reproduce with ChartsDemo

@liuxuan30 liuxuan30 added the bug label Apr 9, 2016
@danielgindi
Copy link
Collaborator

I'm assuming it's because of the move to Swift 2.2.
Apple failed to mention that when they automatically convert a for loop to a Stride, the result is far from the same. Because Stride insists on throwing exceptions when it has nothing to loop over, instead of just doing nothing.

@calkinssean If you can point us to which line of code produces the exception - it could be easily fixed.

danielgindi added a commit to danielgindi/swift that referenced this issue Apr 10, 2016
People expect strides to allow zero size - like any traditional `for` loop that would have just skipped.
Adding an additional condition just for that makes the code messier.

But moreover - Xcode itself expects it to allow `0` length stride.
As Xcode automatically converts old `for` loops to strides, it actually **breaks** code that may in some cases have zero-length strides.

ChartsOrg/Charts#931
@danielgindi
Copy link
Collaborator

Well the stride I know crashes- and you can see it in Stride's source
code... I've sent a PR to Apple

@liuxuan30
Copy link
Member

I see that. the stride cannot be 0, but old c loop will has infinite loop.

@danielgindi
Copy link
Collaborator

Why an infinite loop?

for (var i = 0; i < 0; i +=0) {
  // This will not be called, as "i < 0" is not satisfied
}

@liuxuan30
Copy link
Member

oops, my bad. I mean <= when I said infinite loop

@danielgindi
Copy link
Collaborator

Oops - it's actually my bad, as I didn't see that it's a case of through which is <=.

I'll have to look at the code again to make sure that the extra axis line is not missing in cases where last-first is an exact multiplication of interval.

I'll also need to make tests for Swift Stride to make sure that there are no infinite loop cases.

@danielgindi
Copy link
Collaborator

After running some tests I'm writing for the PR - it looks like the Swift precondition is meant for checking the interval, not the to or through. Will almost definitely cause an infinite loop... Unless the test is less than

@liuxuan30
Copy link
Member

We evolved from crash/not responding after a few minutes to crash directly :)

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