Hello Cocos-2dx community =)
For the past two days I have been trying to resolve the issue of Android’s GL context being lost on app resume. Version 2.1.5 brought in a bug fix for this issue, which I’ve had success with on a few devices. However, the fix doesn’t take in to account textures loaded from an expansion file. I tried reloading textures manually on AppDelegate::applicationWillEnterForeground but I came across some unusual behaviour. Here’s what I discovered:
- The EGL context can be lost AFTER applicationWillEnterForeground
- Reloading textures in applicationWillEnterForeground does not guarantee textures will remain loaded until the next applicationDidEnterBackground event.
- Textures should be reloaded in GLSurfaceView.Renderer.onSurfaceCreated
My current solution is to put an arbitrary delay after applicationWillEnterForeground before reloading textures. A long term fix would be to implement native callbacks for GLSurfaceView.Renderer.onSurfaceCreated and make CCTextureCache/VolatileTexture aware of expansion files.
Hope this helps!
A few links that helped me along the way: