Assertion error on CCObject.cpp line 92 when using texture subrect

Hello,

I’ve published a Cocos2D-X game in Play Store and received some error reports.
In some devices, the game crashes right after the game being launched.

I did some investigation and found out that the usage of sub rect in CCSprites has caused the error to appear in some devices.

Assert error C:/…/cocos2d/cocoa/ccobject.cpp Function:retain line:92

For example, this line would cause error:

CCSprite *mySprite = CCSprite::create("sprite.png", CCRect(0, 0, 120, 120));

This is really annoying since I used a lot of spritesheets in the game.

The devices I tested that runs the game without problem are:

  • Lenovo A790e / Android 2.3
  • Samsung Galaxy Gio GT-S5660 / Android 2.3
  • Sony Xperia U ST25i / Android 2.3
  • Sony Xperia Tipo ST21i / Android 4.0
  • Samsung Galaxy Ace GT-S5830 / Android 2.3
  • Samsung Galaxy S III GT-I9300 / Android 4.1.2
  • HTC Sensation 4G / Android 4.0
  • Cyrus Atompad / Android 4.0 (local tablet brand)

Devices I tested that cannot run the game are:

  • Samsung Galaxy Young GT-S5360 / Android 2.3
  • Samsung Galaxy Nexus GT-I9250 / Android 4.1
  • Huawei U9200 / Android 4.0
  • Samsung Galaxy Tab GT-P1010 / Android 2.2
  • Polytron Wizard Crystal W3430 / Android 4.0

I used Cocos2D-x 2.0.4 on the published game. I also tried using 2.1.1 but I got exactly the same result on the same devices.

Is there any workaround for ths?

anyone?

bump…

I am getting the same error message but it only appears when I try to add a spritesheet.

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("thisspritesheet.plist"); CCSpriteBatchNode *thisspritesheet = CCSpriteBatchNode::create("thisspritesheet.png"); this->addChild(thisspritesheet, 2);

If I comment out this portion of code then the “Assert error /…/cocos2dx/cocoa/CCObject.cpp function:retain line:92” disappears.

Anyone facing the same issue can post a workaround or a fix?

Thanks!

Bump~~

in my version of that file, line 92 is:-
CCAssert(m_uReference > 0, "reference count should greater than 0");

I have seen a number of these type of assert errors when the object I’m trying to retain does not exist (missing file etc).
The m_uReference count never gets incremented as the the object does not get loaded.

I am very sure the file is in the assets folder.

It only occurs on some android devices like Yana Nugraha pointed out.

If anyone can shed some light on a workaround, that would help alot.

I have seen a few comments on games in google play store that this error pops up on their devices.

Regards.

Are you working with large sprite sheets when the error occurs?

Could it be that you are loading an image that’s larger than the device can support?

My sprite sheet has a size of 4096x4096. Which is the maximum that cocos2dx will allow.

Or at least that was the error that was throwing when I tried to use something bigger for the iOS version.

Unless sprite sheet sizes differ between iOS and Android I don’t think this should be the reason why the error occurs.

Regards.

I’m not sure how accurate this is but:-
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Max_size_of_textures_in_cocos2d-x_depends_on_each_platform

I was thinking its more about the what the hardware can support.

I will reduce my texture to 1024x1024 and see if the same issue comes up.

Will update on this thread again.

Thanks Adam!

Hi Adam,

I have tried reducing the size of the sprite sheets but I am still getting the error “/CCObject.cpp function:retain line 92”.

Regards.

My sprite sheets are small so I don’t think that is really the issue…
Also the problem occurs on mid-to-high-end device like Galaxy Nexus as well.

I don’t like to necro, but I thought it was worth mentioning that I had this error and solved it in my use case. Apparently, if you leave out a terminating NULL in a CCSequence, it can trigger this error too.