Black pictures after a playing time

Hi,

My game start well, when I play it for a while, some pictures become black, no lock screen or entering background during this time, I used v2.1.0 and then update to v2.1.3, the problem is still there, does anyone has encounter this, how to fix it ? thanks.

log:

D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0501 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589

Can you describe how to reproduce it?

  1. play the game.
  2. load as many sprites as possible.
  3. at some point, new sprites are loaded as black area. what’s more, gallery app can not be open.
  4. sprite loaded before works fine.
  5. my device is GT-i9100.

还有这个log
OpenGL error 0x0505 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589

Hi,

I have found a similar issue, but in different situations. I’m also finding black screen, but I’m still able to touch the sprites, it is like the sprites are there but they have lost their textures. The situations this happened were:

  • When I was coming back to the game from an Android push notification (restoring the activity)
  • When I restore application from background, but the application was long time in background (all night long). When I restore application from background immediately it is not happening.

The only output I could see are these logs in the LocCat, that appear repeatedly until I close the game:

W/Adreno200-ES20(12583): <__load_uniform_matrix:801>: GL_INVALID_OPERATION
D/cocos2d-x debug info(12583): OpenGL error 0x0502 in […]/cocos2dx/sprite_nodes/CCSprite.cpp draw 589

I was using cocos2d-x 2.1.1 version before and it was not happening. The problem started after I changed to cocos2d-x 2.1.3 version.

I hope it can help.

Thanks in advanced.

I have the same problem. Anytime the game loses focus (even for a second, doesn’t matter how it loses focus: lock screen, text, etc), this one texture of mine turns black.
This is how I am using the texture:

  1. I get data from web and store it in CCTexture2D in memory.
  2. I use this CCTexture2D in memory to create CCSprite in scene.
    I’m using cocos2d-2.0-x-2.04

possible solution: do i have to force a re-fetch of the image? (not ideal for users)

Cid Highwind wrote:

Hi,
>
I have found a similar issue, but in different situations. I’m also finding black screen, but I’m still able to touch the sprites, it is like the sprites are there but they have lost their textures. The situations this happened were:
>

  • When I was coming back to the game from an Android push notification (restoring the activity)
  • When I restore application from background, but the application was long time in background (all night long). When I restore application from background immediately it is not happening.
    >
    The only output I could see are these logs in the LocCat, that appear repeatedly until I close the game:
    >
    W/Adreno200-ES20(12583): <__load_uniform_matrix:801>: GL_INVALID_OPERATION
    D/cocos2d-x debug info(12583): OpenGL error 0x0502 in […]/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
    >
    I was using cocos2d-x 2.1.1 version before and it was not happening. The problem started after I changed to cocos2d-x 2.1.3 version.
    >
    I hope it can help.
    >
    Thanks in advanced.

I have the same problem, was anybody able to fix it?

jb

someone can help us? when the android go to lock screen and then get back the screen will just show the black screen.

dongdong li wrote:

Hi,
>
My game start well, when I play it for a while, some pictures become black, no lock screen or entering background during this time, I used v2.1.0 and then update to v2.1.3, the problem is still there, does anyone has encounter this, how to fix it ? thanks.
>
log:
>
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0501 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589

According to my research, this problem seems to occurs only on devices with Adreno 200 GPU. Also I’ve noticed that debug build works fine on it, the problem appears in release build.

After some time I’ve found out that device is runs out of memory, so in my case, I just switched to 16-bit textures, it can be done by adding this line on start:

CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);

Also you can unload unneeded textures before load new scene, like this:

CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames(); CCTextureCache::sharedTextureCache()->removeUnusedTextures(); CCDirector::sharedDirector()->purgeCachedData();

P.S.:

Also I’ve noticed that debug build works fine on it, the problem appears in release build.

I was wrong about that :slight_smile: Type of build doesn’t matter here, it was my fault. Because of my awkwardness, I put setDefaultAlphaPixelFormat to COCOS2D_DEBUG block, so it affected only debug version. It was fixed and now both versions works OK :wink:

You all have problems with clean unused memory. You need load/unload textures from cache when it’s need.

I also hit this problem. My apps also used lot of graphics.
To remedy the situation, I just follow Mad Max suggestions. The occurrence seem lower but still happened on some devices.
Also, by using kCCTexture2DPixelFormat_RGBA4444, it’s decreased the graphic quality.

Anyway, is it possible to handle texture re-creation better during the the app resume from background?

dongdong li wrote:

Hi,
>
My game start well, when I play it for a while, some pictures become black, no lock screen or entering background during this time, I used v2.1.0 and then update to v2.1.3, the problem is still there, does anyone has encounter this, how to fix it ? thanks.
>
log:
>
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0501 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589
D/cocos2d-x debug info(13584): OpenGL error 0x0502 in /Volumes/macdata/MyDev/tools/cocos/x2.1.3/cocos2d-2.1rc0-x-2.1.3/AmazingPaintingStudio_Amazon/proj.android/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 589

i have also this proplem.
please:
open the annotation

  1. cocos2dx/platform/CCPlatformMacros.h ~~>line 84 #define CC_ENABLE_CACHE_TEXTURE_DATA 1
  2. cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java~~>open the annotation line 167
    3)in android project,find “jin/hellocpp/main.cpp”,open the annotation Line32~43
    this works for me.try it.good luck

I was experiencing this when coming back to the game from the home screen. I did steps 1 & 3 (couldn’t find commented line in step 2) and this seems to have fixed it for me.

I was having a slight variation of this issue on my Xperia Play (running a custom ROM), where any time I slid open or close my gamepad, the screen would become black.

yin maic’s solution solved it, however, now instead of blacking out, the screen instead blacks out and all textures are re-drawn immediately after.
Each time I do, logcat displays this:

06-08 16:40:39.436: D/Cocos2dxActivity(19111): model=R800i
06-08 16:40:39.436: D/Cocos2dxActivity(19111): product=R800i_1253-4437
06-08 16:40:39.436: D/Cocos2dxActivity(19111): isEmulator=false
06-08 16:40:39.526: I/Adreno200-EGLSUB(19111): ConfigWindowMatch:2101: Format RGB_565.
06-08 16:40:39.535: E/(19111): Can’t open file for reading
06-08 16:40:39.535: E/(19111): Can’t open file for reading
06-08 16:40:39.746: D/cocos2d-x debug info(19111): reload all texture
06-08 16:40:41.945: W/Surface(19111): Surface.finalize() has work. You should have called release() (1851040, 0)

Is there any way for it not to have to reload all textures each time this happens?

I have same problem

some times the CCsprite goes to black, some times the whole screen goes to black.

this problem is killing me.

somebody help me

We are having this problem too… Whole screen becomes black sometimes.
Please help us solve this issue!

Same issue here.

I am using a Sony Xperia Z to test my game.
Cocos2d-x verison: cocos2d-2.1rc0-x-2.1.3
Android version: 4.1.2

Easiest to reproduce this error is to lock the screen. After unlocking the screen the game is entirely black and it also takes a while to show the menu buttons which also take a while to respond to input.

Logcat is receiving a HUGE amount of logs.

06-10 15:04:50.589: W/Adreno200-ES20(20773): <__load_uniform_matrix:801>: GL_INVALID_OPERATION 06-10 15:04:50.589: D/cocos2d-x debug info(20773): OpenGL error 0x0502 in /../../../cocos2dx/sprite_nodes/CCSprite.cpp draw 589

This error also occurs with a new empty/clean project with no sprites or anything drawn to the screen, so it was only showing the fps but even then after unlocking it became entirely black.

UPDATE: I uncommented the else statement in jni/hellocpp/main.cpp in the “Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit” method which did something. The game now loads with out the error above but there are still some unrendered area’s. In my case the first number (sprite count?) of the fps display was black.

We also had our app rejected by Amazon (for Kindle Fire devices) because of this. This is how they reproduced it:

  • open game
  • press Sleep button
  • resume from Sleep
  • rotate screen while still locked
  • unlock screen

Result:

  • screen is black, but system is responsive

I think this problem is because of this fix:

http://www.cocos2d-x.org/issues/1613

Apparently it still has some problems.

I’ll update the results once we have the time to debug.

Minggo Zhang, any way that you or someone else can investigate and solve this bug urgently? thanks