Compare commits

...

2 Commits

Author SHA1 Message Date
Hajime Hoshi
dd19552f88 ebiten: update comments
We need more insights about launch modes.
2024-09-13 15:35:34 +09:00
Hajime Hoshi
c077ad70fd cmd/ebitenmobile: bug fix: graceful shutdown on context lost
Closes #3097
2024-09-13 12:06:25 +09:00
2 changed files with 5 additions and 9 deletions

View File

@ -29,13 +29,12 @@ import {{.JavaPkg}}.ebitenmobileview.Renderer;
import {{.JavaPkg}}.{{.PrefixLower}}.EbitenView;
class EbitenSurfaceView extends GLSurfaceView implements Renderer {
// 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_) {
@ -107,7 +106,7 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
}
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);
}

3
run.go
View File

@ -314,9 +314,6 @@ type RunGameOptions struct {
// When StrictContextRestration is false, Ebitengine does nothing special to restore the context and
// relies on the OS's behavior.
//
// As a side note, especially when StrictContextRestration is false, the activity's launch mode should
// be singleInstance, or the activity no longer works correctly after the context is lost.
//
// The default (zero) value is false.
StrictContextRestration bool
}