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 in BezierSpline3D -> getProgressProperties #62

Open
natalia-osa opened this issue Oct 4, 2018 · 2 comments
Open

Crash in BezierSpline3D -> getProgressProperties #62

natalia-osa opened this issue Oct 4, 2018 · 2 comments

Comments

@natalia-osa
Copy link
Contributor

The code crashed in line 58, which is:

let spineSegmentStartIndex: Int = min(Int(absoluteProgress), curvePoints.count - 2 - pad * 2) // Integer time for the index of the starting curvePoint

absoluteProgress is NaN, curvePoints.count is 4, pad is 1.

Unfortunately, I'm not sure why absoluteProgress isn't a number. However, at the moment, it is happening in 100% cases I'm trying to render a route.

@natalia-osa
Copy link
Contributor Author

natalia-osa commented Oct 4, 2018

Ok, so if in init of PolylineNode sampleCount == 1, then when creating geometry of PolylineShader in render func it tries to create positions in

for index in (0..<sampleCount).reversed() {
  let position = polyline.getPositon(atProgress: progressAtSample(index))
  addCap(atPosition: position, withIndex: index)
}

So it iterates from 0 to 0. It tries to progressAtSample with parameter 0. This methods looks like this:

private func progressAtSample(_ sample: Int) -> CGFloat {
  return (CGFloat(sample) / CGFloat(sampleCount - 1))
}

So it tries to return 0 / 0.

@natalia-osa
Copy link
Contributor Author

natalia-osa commented Oct 18, 2018

The crash is also sometimes reproducible also in your demo. Just add polyline drawing to AR component and it will crash.

In the demo it crashed in these lines, but it may be the same issue. Previously code was working fine, recent changes in master broke it.

ImageBuilder.swift:

func addTile(x: Int, y: Int, image: UIImage) {
    context?.draw(image.cgImage!, in: CGRect(origin: CGPoint(x: CGFloat(x) * tileSize.width, y: CGFloat(Int(imageSize.height / tileSize.height) - y - 1) * tileSize.height), size: tileSize)) // crash Thread 24: EXC_BAD_ACCESS (code=1, address=0x118b84000)
}

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