Projects > cpp > Issues > Bug #2877

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

CCSpriteFrameCache + CCTextureCache addImage Bug

Bug #2877 [Closed]
funkata 2013-10-02 19:06 . Updated almost 9 years ago

When using CCSpriteFrameCache addSpriteFramesWithFile and CCTextureCache addImage method, pre existing texture can be corrupted.

How to reproduce this bug:
1. Create a new project in cocos2d-x (I confirmed this bug exist in 2.1.5 and 2.2, don’t know about version < 2.1.5)
2. Make a simple generated PVR file (test.plist and test.pvr) using texture packer (in this case I generate the test.pvr using the cocos2d-x HelloWorld.png)
3. Add that files (test.plist and test.pvr) to the resource.
4. In the HelloWorldScene.cpp, in the init() method, comment all other code and make it like this

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");
    return true;
}
  1. After that, run the project in the simulator, and you will notice that the fps texture is corrupted.

It’s not only PVR files that affected but also pvr.ccz files.

corrupted.png (34.7 kB) funkata, 2013-10-02 19:06

KingHu 2014-01-24 03:27

Fun Dev wrote:

When using CCSpriteFrameCache addSpriteFramesWithFile and CCTextureCache addImage method, pre existing texture can be corrupted.

How to reproduce this bug:
1. Create a new project in cocos2d-x (I confirmed this bug exist in 2.1.5 and 2.2, don’t know about version < 2.1.5)
2. Make a simple generated PVR file (test.plist and test.pvr) using texture packer (in this case I generate the test.pvr using the cocos2d-x HelloWorld.png)
3. Add that files (test.plist and test.pvr) to the resource.
4. In the HelloWorldScene.cpp, in the init() method, comment all other code and make it like this

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");
    return true;
}
  1. After that, run the project in the simulator, and you will notice that the fps texture is corrupted.

It’s not only PVR files that affected but also pvr.ccz files.

Same bug for me (Sorry for my english). I am programing a game. Everything is fine except the Release version in iOS. Somebody said changing the Project->BuildSetting->Optimization Level would be okay. But nothing fixed after I changed the build setting & clean the products & rebuild the release version. After a few days debug (God! 2 days more!). I found the problem, here is the code:
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");
Adding a plist file to the CCSpriteFrameCache, it failed!, But when I execute the same code twice, it work!

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");

Getting inside of the addSpriteFramesWithFile() fun, target line
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str());
pTexture is null first time and not null second time.
This bug only happen in pvr format (also pvr.ccz). Please anyone tell me how to fix the problem!

KingHu 2014-01-24 03:51

@Fun Dev, Thanks @Oren Bengigi, I find the answer here:
http://www.cocos2d-x.org/forums/6/topics/18390?r=43651

henry.sha@gmail.com 2014-06-24 02:21

funkata wrote:

When using CCSpriteFrameCache addSpriteFramesWithFile and CCTextureCache addImage method, pre existing texture can be corrupted.

How to reproduce this bug:
1. Create a new project in cocos2d-x (I confirmed this bug exist in 2.1.5 and 2.2, don’t know about version < 2.1.5)
2. Make a simple generated PVR file (test.plist and test.pvr) using texture packer (in this case I generate the test.pvr using the cocos2d-x HelloWorld.png)
3. Add that files (test.plist and test.pvr) to the resource.
4. In the HelloWorldScene.cpp, in the init() method, comment all other code and make it like this

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("test.plist");
    return true;
}
  1. After that, run the project in the simulator, and you will notice that the fps texture is corrupted.

It’s not only PVR files that affected but also pvr.ccz files.

I encounter this problem, too!
cocos2d-x 2.1.5&2.2.3
And I suspect this problem also makes CCArmature display incorrect with PVR images!

henry.sha@gmail.com 2014-06-24 03:55

I've solved the problem that CCArmature display incorrect with PVR images.
TexturePacker must check the "Premultiply Alpha" option, and cpp must add line:

CCTexture2D::PVRImagesHavePremultipliedAlpha(true);

But FPS is still corrupted as @funkata said!

walzer@cocos2d-x.org 2014-10-08 02:47

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8228

godisagirl 2014-10-10 05:36

http://www.coachoutletstoreinuk.com/ Coach Outlet Online

http://www.coachfactoryoutletanus.com/ Coach Outlet

http://www.coachoutletonlineunsius.com/ Coach Factory Outlet

http://www.coachoutletonlinetur.com/ Coach Outlet Online 

http://www.coachfactoryoutletnbsa.com/ Coach Factory Outlet

http://www.coachfactoryoutletuisa.com/ Coach Outlet Store Online

http://www.coachoutletstorenie.com/ Coach Outlet Store Online

http://www.coachfactorystoreuin.com/ Coach Factory Outlet

http://www.coachfactoryoutletreba.com/ Coach Outlet 

http://www.coachfactoryoutletonlinesius.com/ Coach Handbags Outlet 

http://www.coachoutletonlinetnse.com/ Coach Outlet

http://www.coachoutletnoia.com/ Coach Outlet

http://www.chanleoutletmodi.com/ Chanel Outlet Online

http://www.louisvuittonoutletina.com/ Louis Vuitton

http://www.louisvuittonoutletine.com/ Louis Vuitton Outlet

http://www.guccibeltsoutletbcus.com/ Gucci Belts

http://www.guccibelststco.com/ Gucci Belt

http://www.louisvuittonoutletsnib.com/ Louis Vuitton Outlet

http://www.oakleysunglassescnc.name/ Oakley Sunglasses Outlet

http://www.louisvuittonoutletmoba.com/ Louis Vuitton Outlet

http://www.oakleyssunglassesmobo.com/ Oakley Sunglasses Outlet

http://www.oakleysunglassesmaba.com/ Oakley Sunglasses

http://www.oakleysunglassinsc.com/ Oakley Sunglasses

http://www.louisvuittonoutletinca.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletpft.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletcoms.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletcsc.com/ Louis Vuitton Handbags 

http://www.louisvuittonoutletsnib.com/ Louis Vuitton Outlet Online

http://www.louisvuitton-bagsonlinee.net/ Louis Vuitton Handbags

http://www.louisvuittonoutletori.com/ Louis Vuitton

http://www.louisvuittonoutlettca.com/ Louis Vuitton Handbags

http://www.louisvuittonoutletincn.com/ Louis Vuitton Outlet Online 

http://www.chaneloutletmodi.com/ Chanel Outlet 

http://www.chaneloutletmodo.com/ Chanel Outlet

http://www.chaneloutletinaus.net/ Chanel Outlet

http://www.chaneloutletinfr.com/ Chanel

http://www.oakleysunglassesmodo.com/ Oakley Sunglasses

http://www.okelysuglassesmodo.net/ Oakley Sunglasses Outlet

http://www.oakelysunglassesmod.net/ Oakley Sunglasses

http://www.oakleyoutletshop.us.com/ Oakley Sunglasses

http://www.oakleyoutletonline.us.com/ Oakley Sunglasses Outlet

http://www.oakleysunglassesviews.com/ Oakley Sunglasses Outlet

http://www.raybanshop.name/ Ray Ban

http://www.raybansunglassesshop.name/ Ray Ban Sunglasses

http://www.raybansunglassesmodo.net/ Ray Ban Sunglasses Outlet

http://www.coachoutletonlineptn.com/ Coach Outlet

http://www.coachoutletstoreinuk.com/ Coach Outlet Online

http://www.coachfactoryoutletanus.com/ Coach Outlet

http://www.coachoutletonlineunsius.com/ Coach Factory Outlet

http://www.coachoutletonlinetur.com/ Coach Outlet Online

http://www.coachfactoryoutletnbsa.com/ Coach Outlet Store

http://www.coachfactoryoutletuisa.com/ Coach Outlet Store Online

http://www.coachoutletstorenie.com/ Coach Outlet

http://www.coachfactorystoreuin.com/ Coach Factory Online

http://www.coachfactoryoutletreba.com/ Coach Factory Outlet

http://www.coachfactoryoutletonlinesius.com/ Coach Factory Outlet

http://www.coachoutletonlinetnse.com/ Coach Outlet

http://www.coachoutletnoia.com/ Coach Outlet Store Online

http://www.chanleoutletmodi.com/ Chanel Outlet Online

http://www.louisvuittonoutletina.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletine.com/ Louis Vuitton Handbags

http://www.guccibeltsoutletbcus.com/ Gucci Belt

http://www.guccibelststco.com/ Gucci Belts

http://www.louisvuittonoutletsnib.com/ Louis Vuitton Outlet Online

http://www.oakleysunglassescnc.name/ Oakley Sunglasses Outlet

http://www.louisvuittonoutletmoba.com/ Louis Vuitton Outlet Online

http://www.oakleyssunglassesmobo.com/ Oakley Sunglasses Outlet

http://www.oakleysunglassesmaba.com/ Cheap Oakley Sunglasses

http://www.oakleysunglassinsc.com/ Oakley Sunglasses

http://www.louisvuittonoutletinca.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletpft.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletcoms.com/ Louis Vuitton Outlet

http://www.louisvuittonoutletcsc.com/ Louis Vuitton Handbags 

http://www.louisvuittonoutletsnib.com/ Louis Vuitton Outlet Online

http://www.louisvuitton-bagsonlinee.net/ Louis Vuitton Handbags

http://www.louisvuittonoutletori.com/ Louis Vuitton

http://www.louisvuittonoutlettca.com/ Louis Vuitton Handbags

http://www.louisvuittonoutletincn.com/ Louis Vuitton Outlet Online 

http://www.chaneloutletmodi.com/ Chanel Outlet 

http://www.chaneloutletmodo.com/ Chanel Outlet

http://www.chaneloutletinaus.net/ Chanel Outlet

http://www.chaneloutletinfr.com/ Chanel

http://www.oakleysunglassesmodo.com/ Oakley Sunglasses

http://www.okelysuglassesmodo.net/ Oakley Sunglasses Outlet

http://www.oakelysunglassesmod.net/ Oakley Sunglasses

http://www.oakleyoutletshop.us.com/ Oakley Sunglasses

http://www.oakleyoutletonline.us.com/ Oakley Sunglasses Outlet

http://www.oakleysunglassesviews.com/ Oakley Sunglasses Outlet

http://www.raybanshop.name/ Ray Ban

http://www.raybansunglassesshop.name/ Ray Ban Sunglasses

http://www.raybansunglassesmodo.net/ Ray Ban Sunglasses Outlet

http://www.coachoutletonlineptn.com/ Coach Outlet

http://www.coachoutletstoreinuk.com/ Coach Outlet Online

http://www.coachfactoryoutletanus.com/ Coach Factory Outlet

http://www.coachoutletonlineunsius.com/ Coach Outlet

http://www.coachoutletonlinetur.com/ Coach Online Outlet

http://www.coachfactoryoutletnbsa.com/ Coach Factory Outlet

http://www.coachfactoryoutletuisa.com/ Coach Outlet Store

http://www.coachoutletstorenie.com/ Coach Outlet Store

http://www.coachfactorystoreuin.com/ Coach Outlet Online

http://www.coachfactoryoutletreba.com/ Coach Factory Outlet

http://www.coachfactoryoutletonlinesius.com/ Coach Factory Online

http://www.coachoutletonlinetnse.com/ Coach Factory Outlet

Atom PDF

Status:Closed
Start date:2013-10-02
Priority:Urgent
Due date:
Assignee:-
% Done:

0%

Category:all
Target version:-