6

I've worked on a game and I've tested it with the previous version of iOS, played hundreds of times and I've seen not even a single crash, after I've installed iOS7 and updated xcode I've just tried my app and... now sometimes it crash. The crashes are not happening in a particular moment or action, they're just completely random, sometimes it crash instantly, sometimes after 2-3 games, I've tried to do the same things to check if it's something in particular but seems to be not, or atleast not something noticeable in this way. I'm using sprites and batchnodes in the game scene.

Exactly in this line of code (around 522) in the CCTextureAtlas.m file:

glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); 

since I didn't make any changes to the code I highly doubt that can be something I did, probably it's something related with the changes in iOS7 that affects cocos2d? I'm not even expert with opengl so I have hard time to understand what's happening...

obviously in the game I have some animations ongoing...

additional info:

  • this is NOT happening after a memory warning (I've not memory warning at all).
4
  • 1
    Make sure you don't have something causing opengl calls on another thread/queue which could corrupt the state of the VBO (what glDrawElements is attempting to draw), just before the glDrawElements() invocation. Commented Oct 17, 2013 at 15:39
  • this happens for me too ... but only in simulator (mind you, 'not seeing' something is hard to prove). When running in simulator, after the exception, i can resume from there !!! Commented Oct 18, 2013 at 21:08
  • 1
    I figured it out that in my case the problem was cause by CCLabelBMFont's, probably after iOS7 something happened and while drawing them there's a chance to have a crash. Actually I've replaced them with CCLabelTTF and everything is fine now, but since I don't know yet how to fix it (it's only a workaround) I'm not posting an answer... I've found that probably those are the changes to be made but I've not tried yet: github.com/jllust/cocos2d-x/commit/… Commented Oct 20, 2013 at 17:26
  • @Loudequal that fixed my similar problem. Good catch! Commented Dec 11, 2013 at 13:58

1 Answer 1

4

Adding ccGLBindVAO(0); after every call to glDeleteVertexArrays(1, &_VAOname);, stopped the crashes.

There are three files with this call:

 CCDrawNode:164 CCTextureAtlas:142 CCParticleSystemQuad:164 CCParticleSystemQuad:229 CCParticleSystemQuad:492 

Like so in CCTextureAtlas:

#if CC_TEXTURE_ATLAS_USE_VAO glDeleteVertexArrays(1, &_VAOname); ccGLBindVAO(0); #endif 

I'm using cocos2d-iphone classic 2.2.

The code was here: https://github.com/jllust/cocos2d-x/commit/1f3c1145362c921bf5232c4ffbca4a5245042bae

I made a cocos2d-iphone-classic pull request: https://github.com/zeraien/cocos2d-iphone-classic/commit/817a9c14a3aa1d4c162071521e45e2fcce473d77

Sign up to request clarification or add additional context in comments.

2 Comments

thank you very very very very much..... I got an old project but can't solve it . You are my god.
Glad it was helpful :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.