Issue with Textures being corrupted

I use this method in a few places in my code to generate realtime new textures:

delete m_Image;
if (m_Texture)

auto rt = cocos2d::RenderTexture::create(SizeX * g_TileSize* g_GlobalScalingGame, SizeY * g_TileSize * g_GlobalScalingGame);
rt->setAnchorPoint(cocos2d::Vec2(0, 0));


m_Image = rt->newImage();
m_Texture = new cocos2d::Texture2D();

the m_VisualObject is always a child to the scene. And I keep the texture and image in memory and delete them and release them just before creating a new version of the Visual Object. For some reason sometimes the texture is corrupted and instead of seeing the Tile->GetSprite() Visual/Texture, I end up with some other elements. Sometimes a black screen, sometimes part of the interface sometimes something else. Like if the texture has been released and now the pointer to the texture is pointing somewhere randomly in video memory.

Any idea what could be wrong?

I can ask engineering to help.

The code you have provided has not buggy and it is difficult to determine what the cause of the problem is. It would be better to provide a reproduction project so that we can help you to check this problem.

Unfortunately, I cannot reproduce it. Only players have reported it :frowning: