1

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)
Swift Dev Journal
  • 19,282
  • 4
  • 56
  • 66
MandelDuck
  • 401
  • 5
  • 16
  • Swift 4 is a really old version, why are you using that? What is the OS of the device you're running this on? – EmilioPelaez Aug 14 '22 at 23:38
  • Originally the project was in Swift 2 so I upgraded to Swift 4, but now I upgraded to Swift 5 as well, same issue, the OS is 15.5 on the simulator – MandelDuck Aug 16 '22 at 00:36
  • 1
    The solutions here seem to work https://stackoverflow.com/questions/39519895/sprite-kit-app-crashes-when-run-on-real-device-and-plugged-into-computer – MandelDuck Aug 16 '22 at 00:46

0 Answers0