Tile-engine bug: Multiple sprites initialized with the same SpriteFrame sometimes don't get rendered, or get rendered flipped. (Release builds only)

I’ve created a stripped-down example project to demonstrate this bug, which I assume must be a cocos2d-x bug since it works exactly as expected for debug builds, but not for release builds.

I would appreciate it if anyone could run my example project and see if they have any idea what might be going wrong.

Note: The flipped SpriteFrame bug only appears for me if I use 2 tile types (HelloWorldScene.cpp Line 17). If you uncomment this line and comment out Line 16 so there’s only 1 tile type, many tiles just don’t get rendered.

I’ve zipped the Classes and Resources folder so that they can just be copied straight into an existing project.

Thanks!

TileProjector.zip (854.8 KB)

Some screenshots to demonstrate the problem more clearly. You can see that the debug builds render everything perfectly, but the release builds show 2 separate bugs.

It looks like the more times you reuse a SpriteFrame with Sprite::setSpriteFrame(…), the worse it gets (at least for release-builds).

Although all the tiles are rendered in the bottom right example, there’s half as many sprites sharing the same SpriteFrame, but despite that, some tiles are still drawn upside down.

I just managed to fix this issue by allocating the tile-sprites using Sprite::create() rather than using new Sprite().

Could there perhaps be an assert when cocos objects are allocated without calling the ::create() function? I’ve seen other threads which were resolved the same way, so it seems like an assert or warning could avoid confusion for people who are new / still getting used to the engine.