Make sure renderThread is alive before calling requestExitAndWait() (#3461)

This commit is contained in:
Bart Louwers
2025-05-13 20:37:39 +02:00
committed by GitHub
parent 307470439a
commit bb071bb2e9
3 changed files with 14 additions and 6 deletions

View File

@@ -51,7 +51,7 @@ public abstract class MapLibreSurfaceView extends SurfaceView implements Surface
@Override
protected void finalize() throws Throwable {
try {
if (renderThread != null) {
if (renderThread != null && renderThread.isAlive()) {
// thread may still be running if this view was never
// attached to a window.
renderThread.requestExitAndWait();
@@ -249,7 +249,7 @@ public abstract class MapLibreSurfaceView extends SurfaceView implements Surface
if (detachedListener != null) {
detachedListener.onSurfaceViewDetached();
}
if (renderThread != null) {
if (renderThread != null && renderThread.isAlive()) {
renderThread.requestExitAndWait();
}
detached = true;
@@ -435,9 +435,9 @@ public abstract class MapLibreSurfaceView extends SurfaceView implements Surface
synchronized (renderThreadManager) {
shouldExit = true;
renderThreadManager.notifyAll();
while (!exited) {
while (!exited && this.isAlive()) {
try {
renderThreadManager.wait();
renderThreadManager.wait(100);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}