Sync surface destruction with main thread (#3368)
This commit is contained in:
@@ -84,6 +84,14 @@ abstract class TextureViewRenderThread extends Thread implements TextureView.Sur
|
||||
this.destroySurface = true;
|
||||
this.requestRender = false;
|
||||
lock.notifyAll();
|
||||
|
||||
while (this.hasNativeSurface) {
|
||||
try {
|
||||
lock.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ public class GLTextureViewRenderThread extends TextureViewRenderThread {
|
||||
if (destroySurface) {
|
||||
eglHolder.destroySurface();
|
||||
destroySurface = false;
|
||||
this.hasNativeSurface = false;
|
||||
lock.notifyAll();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,12 +91,14 @@ public class GLTextureViewRenderThread extends TextureViewRenderThread {
|
||||
|
||||
// Initialize EGL if needed
|
||||
if (eglHolder.eglContext == EGL10.EGL_NO_CONTEXT) {
|
||||
this.hasNativeSurface = true;
|
||||
initializeEGL = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// (re-)Initialize EGL Surface if needed
|
||||
if (eglHolder.eglSurface == EGL10.EGL_NO_SURFACE) {
|
||||
this.hasNativeSurface = true;
|
||||
recreateSurface = true;
|
||||
break;
|
||||
}
|
||||
@@ -195,6 +199,7 @@ public class GLTextureViewRenderThread extends TextureViewRenderThread {
|
||||
|
||||
// Signal we're done
|
||||
synchronized (lock) {
|
||||
this.hasNativeSurface = false;
|
||||
this.exited = true;
|
||||
lock.notifyAll();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
mapRenderer.onSurfaceDestroyed();
|
||||
surface.release();
|
||||
surface = null;
|
||||
|
||||
hasNativeSurface = false;
|
||||
}
|
||||
|
||||
// Thread implementation
|
||||
@@ -68,6 +70,7 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
|
||||
if (surface == null) {
|
||||
surface = new Surface(surfaceTexture);
|
||||
this.hasNativeSurface = true;
|
||||
createSurface = true;
|
||||
}
|
||||
|
||||
@@ -111,6 +114,10 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
if (destroySurface) {
|
||||
mapRenderer.onSurfaceDestroyed();
|
||||
destroySurface = false;
|
||||
synchronized (lock) {
|
||||
this.hasNativeSurface = false;
|
||||
lock.notifyAll();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user