The problem: On a device running a problematic iOS version, if u_path_length
is even accessed it breaks the whole SpriteKit view - it just goes all black.
The long explanation:
There seems to be a bug with shaders in versions of iOS previous to 10.2... at least it works on a iOS 10.2 device I have, and it doesn't on a iOS 9.3.5 device.
The things I am working with comes from https://stackoverflow.com/a/41624474/129202
There is a comment there about this issue, but I can't find out how to work around it. And can't find any other references to this issue yet.
// prior to a fix in iOS 10.2, bug #27989113 "SKShader/SKShapeNode: u_path_length is not set unless shouldUseLocalStrokeBuffers() is true"
// add a few points to work around this bug in iOS 10-10.1 ->
// for i in 0...15 {
// path1.addLine( to: CGPoint( x: 0, y: strokeHeight + CGFloat( 0.001 ) * CGFloat( i ) ) )
// }
I am using a shader for a SKShapeNode. The shape is a simple circle. The shader is in my answer here: https://stackoverflow.com/a/41755880/129202
Confirmed working iOS versions
- iOS 10.2
- iOS 10.1.1
Not working
- iOS 9.3.5
- iOS 9.3.4