addImageAsync crashes on Android

Hey guys,

When I use addImageSync it always crashes when the the game enters the foreground (after locking/unlocking or pressing the home button then going back to the app). addImage works fine though, so I think this might be a bug.

Anyone else encounter this problem?

Yes, I have checked it.
#923 is created for it.

Thank you.

Did you run TextureCacheTest then find the bug, or did you use addImageAsync in your codes?

I encountered the crash when I used addImageAsync in my game. I haven’t tried the TextureCacheTest

I have fixed it.
Please refer https://github.com/cocos2d/cocos2d-x/pull/636 for detail info.

Thanks for the quick fix man. It works well now. One thing though I think we should change line 105 in CCTextureCache from:

CCImage::EImageFormat imageType;

To:

CCImage::EImageFormat imageType = (CCImage::EImageFormat) –1; //or create something like kFmtUnknown

Cuz I got a ’variable “imageType’ is being used without being initialized” check failure when I first compiled in Visual Studio.

You are right.
Thank you.