I have a scene with 20ish SKSpriteNodes that are added at run time. I also Add an SKLightNode
However I get a crash with the following log
-[MTLDebugRenderCommandEncoder validateDrawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:function:]:5605: failed assertion `Draw Indexed Primitives Validation indexBufferOffset(12) + (indexCount(222) * 2) must be <= [indexBuffer length](240). ' -[MTLDebugRenderCommandEncoder validateDrawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:function:]:5605: failed assertion `Draw Indexed Primitives Validation indexBufferOffset(12) + (indexCount(222) * 2) must be <= [indexBuffer length](240).
If I wait 10 seconds to add the SKLightNode the crash doesnt happen, also if I disable shadows on the SKSpriteNode the crash doesnt happen.
Fyi this was an old swift 2 project that worked fine, I manually upgraded it to swift 4 and these issues started, any ideas?
the SKLightNode SKSpriteNodes are as follows
let light = SKLightNode();
light.categoryBitMask = 1;
light.falloff = 1;
light.ambientColor = .white
light.lightColor = .white
light.shadowColor = .black
let tree1 = SKSpriteNode(texture: SKTexture(imageNamed: "tree1.png"), color: grayColor, size: CGSize(width: 120, height: 270));
tree1.color = grayColor;
tree1.colorBlendFactor = 1;
tree1.position = CGPoint(x: (self.frame.size.width/2) - 170, y: 730)
tree1.shadowCastBitMask = 1;
tree1.shadowedBitMask = 1;
tree1.name = String(format: "%f", tree1.position.y)