Im using 3.0beta2 and testing my game on android 4.0.
I’m using facebook sdk to share something on facebook, then after the app resumed, I got this error
I’ve done that, you can see my code above.
facebook activity has been called, and brought up to the front, then when it gets back to cocos2dxactivity, it spits error like on post #1
Yep. You use Activity.runOnUiThread() to invoke login.
Sorry for my careless.
I have not idea now.
From the error message, it seems that invoking JNI from different thread.
So after plugin activity back to cocos2d-x activity, did you invoke engine code directly in UI thread?
@siauw, Thanks for your feedback!
What’s your app performance when the error is logged?
Is it crashed? Black screen? No response? Or only have this error log with everything else is well?
Could you upload a demo project to reproduce this problem? Then I can debug & find the reason much quicker.
Thank you once more.
the game goes to black screen when I got that error log, then after a while it’s crashed and back to os menu I just use the code from HelloPlugins. I will sort my code, then I will attach my project here.
any update on this?
it seems like a bug on the renderer. I tested without any plugin-x running. I still got black screen on application resume from os main menu, with this error
I opened CCRenderTexture and there is still this comment
//TODO move this to configration, so we don’t check it every time
/* Certain Qualcomm Andreno gpu’s will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don’t have the same issue with switching frame buffers.
*/
you can use this on the part where EGL is initialize
GLSurfaceView.setPreserveEGLContextOnPause(true)
although i was thinking that the context should be reinitialize when the execution returns to your GL codes.I had this live wallpaper app before where it restarts everything when i go to app drawer then return to home.but there where no errors it just get restarted. it depends on how you initialize your context though, so when i save the context and the focus returns to my codes it just resume from where it was rendering, smooth.
My solution may not apply to your issue but you can at least try. cheers.
I attached the project in here also, so other people can try
I can reproduce the bug only using the hellocpp demo with 2 scenes.
run the game
push the button in the middle to go to next scene
entered next scene, which I render SpriteBatchNode background, and 3 sprites.
push home button on your phone
get back to the game
If it’s still okay then continue with
7. press button on the corner to go back to previous scene
8. press the button in the middle again to go to next scene
9. entered next scene where I render background and 3 sprites , press button on the corner to go back to previous scene again
10. press home button on phone
11. get back to the game again
On my phone that will generate error losing GL context like I describe on my previous post. If it’s not error, try repeat step 8-11 again, maybe 2 more times.
From what I see in the log, the SpriteBatchNode children keep raising every time the game resume from background.
sorry siauw that’s not part of cocos2dx, that’s part of the android sdk and openGL.
I actually haven’t played with cocos2dx-3.0 so i don’t know how the context was initialize but you can look at your project’s activity class (maybe onCreate method) where the EGL was initialize, this is the one you use to configure the GL context to glue or create a bridge between openGL and the native platform display and all the surface, buffers, window size, etc…