LabelBMFont randomly crashes on glDrawElements for cocos2d-x 3.2

LabelBMFont crashes randomly at glDrawElements. Not sure why.

I’m using cocos2d-x 3.2 final.

I know u guys said it’s fixed. NO, it’s NOT! And I don’t think this is a “rare” question since it’s also mentioned in Spine’s forum and stackoverflow:

http://esotericsoftware.com/forum/viewtopic.php?f=9&t=2715

Have you tried using 3.3 ?

Your SO question references cocos2d-iphone.

So are you using -x or -iphone?

Can you provide some sample code that cause the crash?

it’s hard to repro with a few lines of code. There are few situations we identified where the problem happens:

  1. using the same bmfont file to create bmfont labels, but put the label at different z order or attaching them to different nodes.

  2. Not initialized ? (not sure why. It happens in one case where some other labels are not initialized, but somehow it crashes at the glDrawElements() for a bmfont label.

  3. in most cases, it crashes during update() — ok, I mean it seems fine when the bmfont label was just created(u create the label and step over the code, it looks good), but will crash after a few frames.

It also happened to me on 3.3 the same situation on what @likexx said. Is this already fix? Anyone? It crashes on this part:

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

Nevermind got a solution, my hunch is that it won’t work if the thread is busy. I’m calling a lot of network function then after fetching it I create a label from that data, I guess the network keeps the thread busy.

Are you updating label on a background thread ?

I use 3.10 and I have the same problem
falls on

glDrawElements(GL_TRIANGLES, (GLsizei) _triBatchesToDraw[i].indicesToDraw, GL_UNSIGNED_SHORT, (GLvoid*) (_triBatchesToDraw[i].offset*sizeof(_indices[0])) );

exc_bad_access code=1

I met this crash again, now! Could anyone tell me the solution? Please!