problem also for me, Cocos2d-x 2.1.1
I use:
@ private static void sendNativeResponseOnOpenGLThread (final int responseCode, final int errorCode) {
// queue native call on openGL thread
Cocos2dxGLSurfaceView.getInstance().queueEvent(new Runnable() {
Override public void run() { Activity.nativeSetResponse(responseCode, errorCode); } }); }
This method is called after a response from In-App Billing Android.
The variable errorCode tell me if in-app item was purchased or not.
I show a MessageBox (CCLayer) based from this response, but too early.
Infact, Surface is not yet created.
How can I resolve? I have to wait MainActivity.OnResume?
I hoped that Cocos2dxGLSurfaceView.queueEvent() was waiting until GLSurface was active.
The log show an error:
06-30 20:17:02.062: D/Billing(4503): Request 7610932992334889426 of type REQUEST_PURCHASE sent
06-30 20:17:02.062: D/PhoneWindow(4503): couldn’t save which view has focus because the focused view org.cocos2dx.lib.Cocos2dxGLSurfaceView-4054b320 has no id.
06-30 20:17:02.212: I/GLThread(4503): onPause tid=10
06-30 20:17:02.212: I/Main thread(4503): onPause waiting for mPaused.
06-30 20:17:02.232: D/cocos2d-x debug info: ———> EnterBackground
06-30 20:17:02.442: I/GLThread(4503): mPaused is now true tid=10
06-30 20:17:02.442: I/GLThread(4503): releasing EGL surface because paused tid=10
06-30 20:17:02.442: W/EglHelper(4503): destroySurface() tid=10
06-30 20:17:02.452: W/EglHelper(4503): finish() tid=10
06-30 20:17:02.482: I/GLThread(4503): releasing EGL context because paused tid=10
06-30 20:17:02.482: D/cocos2d-x debug: ———> ON_PAUSE
06-30 20:17:41.981: D/inApp(4503): PURCHASED
06-30 20:17:41.981: D/cocos2d-x debug info(4503): setNativeResponse idCall: 2, responseCode: 0, errorCode: 0
06-30 20:17:42.001: I/GLThread(4503): onResume tid=10
06-30 20:17:42.001: I/Main thread(4503): onResume waiting for !mPaused.
06-30 20:17:42.011: E/libEGL: call to OpenGL ES API with no current context
06-30 20:17:42.011: E/cocos2d-x assert: /Users/xxxxxx/Documents/lib/cocos2d-2.1beta3-x-2.1.1/cocos2dx/misc_nodes/CCRenderTexture.cpp function:initWithWidthAndHeight line:332
06-30 20:17:42.051: I/GLThread(4503): mPaused is now false tid=10
06-30 20:17:42.051: W/EglHelper(4503): start() tid=10
06-30 20:17:42.061: W/EglHelper(4503): createContext com.google.android.gles_jni.EGLContextImpl-405f0f48 tid=10
06-30 20:17:42.061: D/cocos2d-x debug: ———> ON_RESUME
06-30 20:17:42.071: W/GLThread(4503): egl createSurface
06-30 20:17:42.071: W/EglHelper(4503): createSurface() tid=10
06-30 20:17:42.071: E/libEGL(4503): eglCreateWindowSurface format=4
06-30 20:17:42.071: W/GLThread(4503): onSurfaceCreated
06-30 20:17:42.261: D/cocos2d-x debug info(4503): reload all texture
06-30 20:17:42.732: W/GLThread(4503): onSurfaceChanged(480, 800)
06-30 20:17:42.732: D/cocos2d-x debug info: ———> EnterForeground