Open natalia-osa opened 6 years ago
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
.
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)
}
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
isNaN
,curvePoints.count
is4
,pad
is1
.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.