Are you using a texture map or are they all individual images that’s moving in and out of cache could it be phone freeing up memory space while in background? I have not had this but I use Texture map one big image. ohh edit is it you need to say sprite->retain();
to keep it then you have to sprite->release();
sound like there out cache or something Texture packer has a get upset if you go over 2048x 2048 size so I wonder if its phone needing resource when they go background. What happens if you do a cocos2dx ->retain(); thought that was meant to stop the flushing? dose it report “Texture flushed” because in Cocos2d-x is not an error message, but rather a notification that the graphics hardware has run out of memory. I not experienced this myself hopefully some one can help.
Thanks. This is probably what is happening. But I see that the solution they propose is to close the app if the context is lost. But I do not see how they achieve it. The online line of code mentioned is already in the current version of 3.17.2.
In that case, you can work around this issue by reloading everything. How you handle that is entirely up to you, but a trick I personally use is to add a dummy cocos2d::Scene at the start of the scene stack, and when you detect that you need to reload, you use popToRootScene or popToSceneStackLevel to get back to it, and then do a pushScene instantly with the first real scene that will load the required resources.
The reason for this is that everything in the popped scenes should be unloaded and those scenes freed, so effectively you’re starting all over again without having dangling resources in memory.
How you detect the need to reload resources is up to you. You could add an event listener for EVENT_COME_TO_BACKGROUND, and every time you receive it, check if the texture is cached via TextureCache::getTextureForKey(). That event is used if CC_ENABLE_CACHE_TEXTURE_DATA is enabled, which seems to be the case for Android.