Skip to content

Commit

Permalink
cmd/ebitenmobile: bug fix: graceful shutdown on context lost
Browse files Browse the repository at this point in the history
Closes #3097
  • Loading branch information
hajimehoshi committed Sep 14, 2024
1 parent dc5869f commit a3fa7df
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/ebitenmobile/_files/EbitenSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import {{.JavaPkg}}.{{.PrefixLower}}.EbitenView;

class EbitenSurfaceView extends GLSurfaceView implements RenderRequester {
// As GLSurfaceView can be recreated, the states must be static (#3097).
static private boolean errored_ = false;
static private boolean onceSurfaceCreated_ = false;
static private boolean contextLost_ = false;

private class EbitenRenderer implements GLSurfaceView.Renderer {

private boolean errored_ = false;
private boolean onceSurfaceCreated_ = false;
private boolean contextLost_ = false;

@Override
public void onDrawFrame(GL10 gl) {
if (errored_) {
Expand Down Expand Up @@ -100,7 +99,7 @@ private void onErrorOnGameUpdate(Exception e) {
}

private void onContextLost() {
Log.v("Go", "Kill the application due to a context lost");
Log.e("Go", "The application was killed due to context loss");
// TODO: Relaunch this application for better UX (#805).
Runtime.getRuntime().exit(0);
}
Expand Down

0 comments on commit a3fa7df

Please sign in to comment.