Locking the phone and unlocking destroys all textures

Locking the phone and unlocking destroys all textures
0.0 0


When running a scene: If I press the lock button on the phone and unlock to go back to the app, all the textures get destroyed and logcat shows continuously:

IMGSRV : bufobj.c:943: glBufferSubData: No memory for object data

This issue happens only on Android, iOS works fine. I saw in the release notes that a similar bug was already fixed. Am I missing any flags/settings?


Problem with per after applicationWillEnterForeground

hello, Diego,
on android, you should used ->end(true) to end rendering to texture as you can see in the function below:
void CCRenderTexture::end(bool bIsTOCacheTexture);


o, on android, the parameter is set to true defaultly,

in the latest code on github, it should be ok.
and what is the engine version you are using?


Hi RongHong,

Actually, I am using the latest code on github. So supposedly I should not have this issue. Any suggestions?


sorry, i misunderstanded your meaning right now,

on android, when the app enters the badkground, the texture data would lose, so the engine has cashed the texture infomation by default.
please make sure that the macro CC_ENABLE_CACHE_TEXTTURE_DATA is not 0.

for more information, you could refer to CCTextureCache,
if you could debug it, and provide more information, it will be appreciated,

btw, what is the machine you are using?


I’ll try to get more debug info. I’m testing with a Motorola Droid phone.


I was trying to log the calls to CCRenderTexture::end() (which calls addDataTexture), but the only places that this function is called is from CCTransitionRadial.cpp,
and CCTransition.cpp. Where are the textures marked for cached on Android?



I was tracing the volatile class calls and it seems to me that sprites created via CCSprite::spriteWithFile are being cached but the ones created via CCSprite::spriteWithSpriteFrameName are not. Could be this the issue?



Just to add more information, I am using two approaches in the same scene:

  1. Sprites created with CCSprite::spriteWithFile and added to a scene. Those are restored ok when locking/unlocking the phone
  2. Sprites created with CCSprite::spriteWithSpriteFrameName. I just retained those sprites and didn’t add them to the scene, and I used visit() to draw their textures. Those are the one that get corrupted when locking/unlocking the phone.

Is that a bug in the Android implementation?

Thanks for your help


hi, Diego, i think this may be a bug, i will check this, and if it is, i will create an issue for it, thank you for your work.


Thanks RongHong,

Please let me know if there is any additional testing I can help you with. This is my #1 issue right now, and would really appreciate it it can get solved.

Thanks again,


ok, Bug #759 has been created for it


I have the same problem… there is an solution?

RongHong Huang wrote:

ok, Bug #759 has been created for it


Now its working (on master) i tested on Nexus 4