Some assets become black after coming back from background

Some assets become black after coming back from background
0

#1

Hi,

We have an Android game with PVR graphics. It works fine in all devices, but when I try to connect to FB, go for a while to another game, etc (whatever that takes the game to the background), and then bring him back to the foreground, some assets appear in black color…

We are using cocos2dx 2.2.1 for this project.

Anybody else is experiencing this situation? Thanks.


#2

@plungeint
Is your game running on android?

I just run TestCpp in version 2.2.1 on android. There isn’t any problems with PVR graphics when it going to background/foreground.
There maybe two reasons of the situation you mentioned:
1. The texture is not reloaded when the game going to foreground.
2. The memory of your device is not enough for reloading the textures.

If the assets appear in black color not stable (Sometimes a.pvr becomes black, sometimes b.pvr becomes black), I think the reason is the second one : memory is not enough.

I think you can take a test on many other devices. If the problem always appeared, you’d better upload a demo which can reproduce the problem. Then I can take a look at it, and try to solve the problem.

Thanks for your feedback!


#3

Hi,

The game is running on Android yes.

I also think is #2. We tried to optimize the spritesheets so each screen uses only the right asdets, and we are removing unused assets from the shared cache.

Do you recommend any other action for saving memory?

Also, do you know if this problem can be detected from the code, maybe checking the available memory?

Thanks,

Jesus


#4

@plungeint
I’ve no idea how to detect the available memory of devices.
I think you’d better check your logic code. Is there any memory leak? For example, track the destruct method of many classes, take a look at : Whether an object is destructed when it’s unused.

Hope it’s helpful.


#5

@plungeint

It may be loading it in thread other than main one. We also had this kind of problem. So for android we scheduled method (using ScheduleOnce of CCNode class). Not sure this is proper way or not.