0

I have problem with my game on Android: when I deactivate the screen by pressing power button in the game activity and then wake up the phone I have black screen for something about one minute and then application crashes. When I pause activity by pressing home button and then return to the game everything looks fine.

This the only entrance in logs about my app which I found after wake up:

12-11 18:27:18.187: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:18.442: WARN/WindowManager(19653): App freeze timeout expired.
12-11 18:27:18.442: WARN/WindowManager(19653): Force clearing freeze: AppWindowToken{40f140c8 token=Token{412d25e8 ActivityRecord{40eb01a0 pl.priv.robertszuba/pl.priv.mallwar.game.GameActivity}}}
12-11 18:27:20.212: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:20.512: WARN/ActivityManager(19653): Activity idle timeout for ActivityRecord{40eb01a0 pl.priv.robertszuba/pl.priv.mallwar.game.GameActivity}
12-11 18:27:20.737: DEBUG/dalvikvm(19653): GC_EXPLICIT freed 1532K, 46% free 9743K/17735K, paused 13ms+7ms
12-11 18:27:22.237: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:24.262: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:26.337: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:28.457: WARN/InputConnectionWrapper.ICC(19863): Timed out waiting on IInputContextCallback
12-11 18:27:54.107: DEBUG/dalvikvm(20893): GC_CONCURRENT freed 1788K, 32% free 6141K/8967K, paused 3ms+5ms
12-11 18:28:06.597: DEBUG/dalvikvm(19653): GC_CONCURRENT freed 1832K, 45% free 9805K/17735K, paused 3ms+5ms

When I tried to debug my app I saw that it is paused correctly and after wake up onResume is called and everything in onResume is done well, but there is no onSurffaceCreate called after it.

genpfault
  • 51,148
  • 11
  • 85
  • 139
gandalfml
  • 908
  • 1
  • 10
  • 23

1 Answers1

0

When the application is Paused, the OpenGL context is not valid when resumed. You need to upload again your data, objects and textures, into the driver memory. I unload and reload data upon each onPause/onResume, it is safer.

This link contains more info: http://developer.android.com/reference/android/opengl/GLSurfaceView.html

A GLSurfaceView must be notified when the activity is paused and resumed. GLSurfaceView clients are required to call onPause() when the activity pauses and onResume() when the activity resumes. These calls allow GLSurfaceView to pause and resume the rendering thread, and also allow GLSurfaceView to release and recreate the OpenGL display.

Check this repo for some tips on how to handle it: https://github.com/TraxNet/ShadingZen (All engine assets extend from Resource class and contains logic to load and unload data when app is paused/resumed).

Trax
  • 1,890
  • 12
  • 15
  • I have GLSurfaceView.onPause in onPause method in my activity and onResume in resume method. In onSufaceCreate I also reload all textures, but as far as I know(it's not only my project, but I will check it tommorow) textures aren't released in onPause. I'll check the ShadingZen repo tommorow, but thanks for help so far. – gandalfml Dec 11 '12 at 20:13
  • I remember I had similar problems and moved the logic to onPause/onResume and now works like a charm. If you find something different please let me know. Cheers. – Trax Dec 11 '12 at 20:31