mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
cmd/ebitenmobile: call setPreserveEGLContextOnPause(true) whatever the option is
We found that an app freezes for a little while when resuming it. In order to improve user experience, always use setPreserveEGLContextOnPause(true) whichever StrictContextRestoration is true or false.
This commit is contained in:
parent
6a51e5b003
commit
fcef0a7c29
@ -96,6 +96,7 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
|
|||||||
private void initialize() {
|
private void initialize() {
|
||||||
setEGLContextClientVersion(3);
|
setEGLContextClientVersion(3);
|
||||||
setEGLConfigChooser(8, 8, 8, 8, 0, 0);
|
setEGLConfigChooser(8, 8, 8, 8, 0, 0);
|
||||||
|
setPreserveEGLContextOnPause(true);
|
||||||
// setRenderer must be called before setRenderRequester.
|
// setRenderer must be called before setRenderRequester.
|
||||||
// Or, the application crashes.
|
// Or, the application crashes.
|
||||||
setRenderer(new EbitenRenderer());
|
setRenderer(new EbitenRenderer());
|
||||||
@ -125,7 +126,6 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void setStrictContextRestoration(boolean strictContextRestoration) {
|
public synchronized void setStrictContextRestoration(boolean strictContextRestoration) {
|
||||||
strictContextRestoration_ = strictContextRestoration;
|
strictContextRestoration_ = strictContextRestoration;
|
||||||
setPreserveEGLContextOnPause(!strictContextRestoration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean hasStrictContextRestoration() {
|
private synchronized boolean hasStrictContextRestoration() {
|
||||||
|
13
run.go
13
run.go
@ -302,17 +302,20 @@ type RunGameOptions struct {
|
|||||||
//
|
//
|
||||||
// StrictContextRestration is available only on Android. Otherwise, StrictContextRestration is ignored.
|
// StrictContextRestration is available only on Android. Otherwise, StrictContextRestration is ignored.
|
||||||
//
|
//
|
||||||
// When StrictContextRestration is false, Ebitengine tries to rely on the OS to restore the context.
|
|
||||||
// In Android, Ebitengien uses `GLSurfaceView`'s `setPreserveEGLContextOnPause(true)`.
|
// In Android, Ebitengien uses `GLSurfaceView`'s `setPreserveEGLContextOnPause(true)`.
|
||||||
// This works in most cases, but it is still possible that the context is lost in some minor cases.
|
// This works in most cases, but it is still possible that the context is lost in some minor cases.
|
||||||
// With StrictContextRestration false, the activity's launch mode should be singleInstance,
|
|
||||||
// or the activity no longer works correctly after the context is lost.
|
|
||||||
//
|
//
|
||||||
// When StrictContextRestration is true, Ebitengine tries to restore the context more strictly.
|
// When StrictContextRestration is true, Ebitengine tries to restore the context more strictly
|
||||||
// This is useful when you want to restore the context in any case.
|
// for such minor cases.
|
||||||
// However, this might cause a performance issue since Ebitengine tries to keep all the information
|
// However, this might cause a performance issue since Ebitengine tries to keep all the information
|
||||||
// to restore the context.
|
// to restore the context.
|
||||||
//
|
//
|
||||||
|
// 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.
|
// The default (zero) value is false.
|
||||||
StrictContextRestration bool
|
StrictContextRestration bool
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user