开发者

Activity pause timeout after calling GLSurfaceView.onPause()

I have a game using OpenGL. I've built off of the examples, for the most part, having the Main Thread, Renderer Thread (GLSurfaceView.Renderer) and added a GameLogic thread as well. When the game is executed, everything seems to run through perfectly. When back is pressed and onPause() is fired, I'm also firing the GLSurfaceView()'s onPause, but I'm having a "crash" at that point. Here's the MainActivity's onPause:

@Override
protected void onPause() {
    Log.d("Main", "Pre- Super onPause");
    super.onPause();
    Log.d("Main", "Post- Super onPause");
    mGSGLView.onPause();
    Log.d("Main", "Post- GL onPause");
}

Each log point is reached except the last. In logcat, immediately following the "Post Super onPause" line, I get an Activity pause timeout.

I am not overriding onPause in the GLSurfaceView class... and as far as I know this had been working for me for some time, but recently started occurring when I started getting a completely black screen on the second time I tried to run my game which sits until finally getting an ANR. 95% of my game runs natively. Similar to the San Angeles exampl开发者_JAVA技巧e, the Renderer calls to onDraw, for instance call a NativeDraw function instead of java. The same is true for the onSurfaceCreated, onSurfaceChanged, and I also call a native GameLogic method in the logic thread (basically all that is called there is a thread sleep and that logic method.)

I hope I've given enough information, please let me know if there is anything else I should be providing.

EDIT - Well... I've actually narrowed down the issue to a native function call where I'm freeing certain pointers that had previously had memory allocated for them with malloc(). My code there looks okay, but if I omit the call, everything works okay, so my free() calls must be corrupting something...


Okay, I'm only answering this myself because the solution was so specific to my own code that no one would have been able to.

If you have memory allocated on the native side, take care not to free it until after you are sure no other code will be trying to access it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜