I just don't understand what is going on since I migrated to Swift 2. I have a Tabbed application and I am getting this error:
<CAEAGLLayer: 0x7fb2e053fb40>: calling -display has no effect.
Assertion failed: (length + offset <= _length), function commit_data,
file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet_Sim/Jet-1.50/Jet/jet_types_OpenGL.h, line 863.
I know it is really vague but I don't know where to start looking for bugs. Thanks.
Edit: I just realized it might be related to the fact that I am trying to embed a GameViewController into the TabbedController. However, it did not cause any error before iOS 9.0. Any clue?
Ok, so the problem was with SKShapeNode. I was drawing ring portions with too many vertices. By decreasing the number of steps in the following function, the problem disappeared!!
func drawPortion2(r1:CGFloat, r2:CGFloat, angle1:CGFloat, angle2:CGFloat, fillColor:UIColor, steps:Int)->SKShapeNode{
let vertices=UnsafeMutablePointer<CGPoint>.alloc(2*steps);
let stepsF=CGFloat(steps);
for j in 0..<steps{
vertices[j]=CGPoint(x: r2*cos(angle2-CGFloat(j)*(angle2-angle1)/stepsF), y: r2*sin(angle2-CGFloat(j)*(angle2-angle1)/stepsF));
}
for j in 0..<steps {
vertices[steps+j]=CGPoint(x: r1*cos(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF), y: r1*sin(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF));
}
let portion=SKShapeNode(points:vertices, count: 2*steps);
//portion.position=centerPos;
portion.fillColor=fillColor;
return portion;
}
来源:https://stackoverflow.com/questions/32677503/spritekit-and-uikit-compatibility-opengl-error-when-migrating-to-swift-2