Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ public void onPause() {

public void onResume() {
mGLThread.onResume();
// Queue an event to force texture validation on resume
mGLThread.queueEvent(new Runnable() {
@Override
public void run() {
// This will trigger texture validation in renderer
android.util.Log.d("GLWallpaperService", "Resume texture validation queued");
}
});
}

public void queueEvent(Runnable r) {
Expand Down Expand Up @@ -364,7 +372,12 @@ public GL createSurface(SurfaceHolder holder) {

public boolean swap() {
mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
int error = mEgl.eglGetError();
if (error == EGL11.EGL_CONTEXT_LOST) {
Log.w("GLWallpaperService", "EGL context lost - textures need to be reloaded");
return false;
}
return true;
}

public void destroySurface() {
Expand Down Expand Up @@ -557,7 +570,12 @@ private void guardedRun() throws InterruptedException {
}
if ((w > 0) && (h > 0)) {
mRenderer.onDrawFrame(gl);
mEglHelper.swap();
if (!mEglHelper.swap()) {
// Context lost - force surface recreation to reload textures
Log.w("GLThread", "Context lost detected, forcing surface recreation");
tellRendererSurfaceCreated = true;
changed = true;
}
Thread.sleep(10);
}
}
Expand Down Expand Up @@ -639,6 +657,15 @@ public void onResume() {
synchronized (sGLThreadManager) {
mPaused = false;
mRequestRender = true;
// Force texture reload on resume to handle context loss during pause
Log.d("GLThread", "Resume detected, requesting texture reload");
queueEvent(new Runnable() {
@Override
public void run() {
// Texture reload will be handled in onSurfaceCreated if needed
Log.d("GLThread", "Resume event processed");
}
});
sGLThreadManager.notifyAll();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public void Draw(float[] viewMatrix, float[] projectionMatrix) {
// Bind shader and set uniforms
bindShader();

// Set texture (using flipped texture)
// Validate and set texture (using flipped texture)
if (!TextureUtils.isValidTexture(SinkerService.textures[1])) {
android.util.Log.e("BackgroundGraveyard", "Flipped texture is invalid!");
return;
}
TextureUtils.bindTexture(0, SinkerService.textures[1]);

// Set blend mode to additive (0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void Draw(float[] viewMatrix, float[] projectionMatrix) {
android.util.Log.e("CenterGraveyard", "Shader program is 0!");
return;
}
if (SinkerService.textures[0] == 0) {
android.util.Log.e("CenterGraveyard", "Texture is 0!");
if (!TextureUtils.isValidTexture(SinkerService.textures[0])) {
android.util.Log.e("CenterGraveyard", "Texture is invalid!");
return;
}
if (vao == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,18 @@ else if(Isvert.equals("big"))

@Override
public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl, javax.microedition.khronos.egl.EGLConfig arg1) {
// Delete old textures if they exist
if (textures[0] != 0 || textures[1] != 0) {
android.util.Log.d("SinkerService", "onSurfaceCreated called - reloading textures");

// Delete old textures if they exist and are valid
if (TextureUtils.isValidTexture(textures[0]) || TextureUtils.isValidTexture(textures[1])) {
android.util.Log.d("SinkerService", "Deleting old textures");
TextureUtils.deleteTextures(textures);
}

// Reset texture handles to avoid using invalid handles
textures[0] = 0;
textures[1] = 0;

// Load textures using new utility
int[] newTextures = TextureUtils.loadTextureWithFlipped(context, R.drawable.gr);
if (newTextures != null) {
Expand Down