I have the same problem, second run onCreateEngine() of wallpaper service crash;
Somebody can tell right initialization/destroy sequence?
I try next -
onCreateEngine() {
return = new MyEngine();
}
//in engine
onCreate(){
executor = Executors.newSingleThreadExecutor();
}
onDestroy(){
executor.shutdownNow();
super.onDestroy();
}
onSurfaceCreated(){
//init gl/egl
EGLConfig config = null;
egl = (EGL10) EGLContext.getEGL();
glDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
int[] version = new int[2];
egl.eglInitialize(glDisplay, version);
int[] configSpec = new int[]{EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};// {EGL10.EGL_RED_SIZE, 5, EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
EGLConfig[] configs = new EGLConfig[1];
int[] numConfig = new int[1];
egl.eglChooseConfig(glDisplay, configSpec, configs, 1, numConfig);
config = configs[0];
glc = egl.eglCreateContext(glDisplay, config, EGL10.EGL_NO_CONTEXT, null);
glSurface = egl.eglCreateWindowSurface(glDisplay, config, holder, null);
egl.eglMakeCurrent(glDisplay, glSurface, glSurface, glc);
gl = (GL10) (glc.getGL());
//create renderer
renderer = new MyRenderer();
renderer.onSurfaceCreated(gl, config);
//in renderer.onSurfaceCreated create word, textures objects etc
}
onSurfaceDestroyed(final SurfaceHolder holder) {
super.onSurfaceDestroyed(holder);
egl.eglMakeCurrent(glDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
egl.eglDestroySurface(glDisplay, glSurface);
egl.eglDestroyContext(glDisplay, glc);
egl.eglTerminate(glDisplay);
mVisible = false;
}
// on surfaceChange & onVisibilityChanged has only logic for call draw command in executor