Reputation: 11
I'm a beginner in SpriteKit world and now I'm doing animation through SKWarpGeometryGrid
. When I have a large number of
sourcePositions/destinationPositions it fulls my buffer and I have the next crash: validateIndexBuffer:131: failed assertion `indexBufferOffset(0) + (indexCount(4704) * 2) must be <= indexBuffer length.'
Sprite Kit app crashes when run on real device and plugged into computer
This answer was helpful and there is no crash now, but the animation stopped working and the image disappears from screen now and then.
What does debugger says:
2018-06-07 14:27:27.102269+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5) 2018-06-07 14:27:27.102352+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Caused GPU Hang Error (IOAF code 3) 2018-06-07 14:27:27.102389+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5) 2018-06-07 14:27:27.156201+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5) 2018-06-07 14:27:27.156278+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Caused GPU Hang Error (IOAF code 3) 2018-06-07 14:27:27.156311+0300 LiveGram[15259:5348410] Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5) 2018-06-07 14:27:27.158508+0300 LiveGram[15259:5348408] Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (IOAF code 4) 2018-06-07 14:27:27.158586+0300 LiveGram[15259:5348408] Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (IOAF code 4) 2018-06-07 14:27:27.158613+0300 LiveGram[15259:5348408] Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (IOAF code 4)
Does anybody know what I'm doing wrong and how may I fix it?
Upvotes: 1
Views: 588
Reputation: 1
SKAction.wait
work good but in my case DispatchQueue.global().asyncAfter(deadline: .now() + 0.1)
is more flexible and worked better.
But anyway this is not good choice for handling this bug because for really huge animating app still crashes.
Upvotes: 0
Reputation: 100
I was having this type of issue and just solved it. It happens when you give too much work to the hardware and the GPU cannot process it so fast.
What you can do to avoid crashing is this: In Xcode: 1.Command+Option+R 2.Options Tab 3.Set Metal API Validation to Disabled
It should prevent the app to crash but the problem still there.
What you can do next is search you code to know where exactly the problem is. I' made this way:
Comment parts of your code and run the app to see if the error still there, like this:
/* //Put this at the beginning
CODE
.
.
.
CODE
*/ //This at the end
If the error still there, uncomment this part of code and comment the next one, do this until you do not have the issue anymore. Then you will continue commenting your code, but in small parts inside the problem portion until you find what exactly is causing it. This happens when you
addChild(This one needs hard GPU processing)
In my case was when i added a LightNode. My solution was create an SKAction:
let action = SKAction.wait(forDuration: 1) //Try different time durations
scene.run(action, completion:
{
code that is causing the problem
})
This way you fragment the processing power needed and give a break to the hardware.
Hope it helps!
Upvotes: 1