• Bugs
  • cocos2d-x 3.1 runtime crash in PolygonBatch

Hi,

Seem to be experiencing a crash in the PolygonBatch::flush method (I've just done a pull on spine runtimes so am using latest version)...

Crashes on the line (EXC_BAD_ACCESS)...

   glDrawElements(GL_TRIANGLES, trianglesCount, GL_UNSIGNED_SHORT, triangles);

if it helps a quick watch shows trianglesCount = 24 and triangles = 0/nil

Let me know if I can help with any other additional info...

Thanks

Related Discussions
...

triangles is assigned in initWithCapacity and then never changed. How did you get it to be 0? :wonder:

Nate :

triangles is assigned in initWithCapacity and then never changed. How did you get it to be 0? :wonder:

Sorry just dbl checked Xcode mis-lead me triangles has a address with a value of 0 at its location, not triangles = nil.

If it helps the problem is occurring on a scene transition, so maybe the polygon batch flush is happening on something that has become deallocated?

Update: found the code thats causing problem (being run on init scene)....

    this->angelActivityAnim = SkeletonAnimation::createWithFile("spine/angel-activity.json", "spine/angel-activity.atlas", 1);
    this->angelActivityAnim->setAnimation(0, "flying", true);
   this->angelActivityAnim->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 40));
    spSkeleton_setSkinByName(this->angelActivityAnim->skeleton, "off");
    spSkeleton_setSlotsToSetupPose(this->angelActivityAnim->skeleton);
    this->angelActivityAnim->setScale(Director::getInstance()->getContentScaleFactor() * 0.25);
   this->addChild(this->angelActivityAnim);

Ive added anim file as attachment if helps...

The example switches between the spineboy and goblins scenes without issue, not sure why your skeleton would be different. What makes you sat the code you posted is the problem?

Nate :

The example switches between the spineboy and goblins scenes without issue, not sure why your skeleton would be different. What makes you sat the code you posted is the problem?

Removing it = no crash, adding back in = crash 🙂. In polygon batch i saw the texture size was 256x128, and thus was able to pinpoint to that anim as was only one that used that texture size 🙂

Update: seems to be same problem in other parts of my app also.

I have the very same crash happened in my app too, I will try to locate the cause but this could be common issue.

Yay 🙂 i just seen you've fixed bug thanks Nate 🙂

btw since cocos 3.1 is final you could update the Matrix/Vector2 to the Mat4/Vec2.

You could also add the following to SkeletonRenderer.cpp to remove warning that is missing.

        case SP_ATTACHMENT_BOUNDING_BOX: {
            break;
        }

Thanks again 🙂

I've updated spine-cocos2dx/3.1 to cocos2d 3.1 final. 🙂 I fixed the warning, thanks.

Thanks great stuff 😃

3 个月 后

Hi there, I think the same crash happened for cocos2d-x 3.2 runtime. The triangles is 0
It happened after I create LabelBMFont, whether as the children or as the sibling in the same empty Node