Is CCSpriteBatchNode broken on Android? RRS feed

  • Question

  • User62409 posted

    Hi all,

    I am experiencing an OpenGL error & crash on Android and the best I can tell is that it has something to do with CCSpriteBatchNode - I hope someone here can help me, either by telling me I'm wrong about CCSpriteBatchNode being broken, or by showing me a way to fix it.

    I have developed a game using CocosSharp and it works great on iOS. I'm trying to port it to Android now. I've managed to boil the issue down into a new, empty game project and can reproduce the issue 100% of the time on seemingly any device. If I create a CCSpriteBatchNode and add a few sprites, they appear just fine until you hit the "home" button on the device and then relaunch the app, and it crashes with various OpenGL errors (depending on the device).

    I actually noticed the issue first with CCLabelBMFont, which is built on top of CCSpriteBatchNode. I don't use CCSpriteBatchNode directly in my code anywhere. My work around was to make some light modifications to CCLabelBMFont to use CCSprite objects instead. I know this is a hack and will result in a performance hit but I use very little text so I don't think it will be a problem for me.

    I have set up a bare-bones project on GitHub so you can see it in action: https://github.com/alexbrombal/cocossharp-brokenbatch

    You should be able to clone this and run it easily if you have the Android 4.4 SDK installed.

    1. Launch the project on an Android device.
    2. You should see a few "rainbow boxes". The top 3 are regular CCSprite objects, the bottom 3 are CCSprite objects within a CCSpriteBatchNode object.
    3. Hit the device's home button.
    4. Reopen the application.
    5. The app will either crash because of an OpenGL error, or the bottom 3 sprites will not appear.

    On a Samsung Galaxy Note 3, I see this error:

    [Adreno-ES20] <gl_draw_error_checks:580>: GL_INVALID_OPERATION

    On Nexus 7, I see this error:

    [libEGL] eglMakeCurrent:671 error 3009 (EGL_BAD_MATCH)

    These are the only errors I see, and there is no stack trace or dump of any kind in the console window.

    Thanks for your help!

    Tuesday, September 16, 2014 4:15 PM


  • User47368 posted

    Hi Alex,

    Sorry for the delay and thanks for the detailed description/ sample project that showcased the issue. The summary is that this ended being an issue with an older version of MonoGame that was packaged with CocosSharp that has since been updated. The upcoming CocosSharp NuGet release will include a newer version of MonoGame that should resolve the problems that appear when Pausing/Resuming on Android.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, September 22, 2014 2:16 AM