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)
	m_Texture->release();

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

cocos2d::Director::getInstance()->getRenderer()->render();

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

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: