fix: make render orchestrator teardown safe
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
tei
2026-10-07 08:41:08 +09:00
parent d29e84c1a9
commit 64cf8f4435
13 changed files with 1483 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package org.maplibre.android.maps.renderer.surfaceview;
import android.content.Context;
import android.util.Log;
import android.view.Surface;
import android.view.View;
@@ -28,11 +29,13 @@ public class SurfaceViewMapRenderer extends MapRenderer {
surfaceView.setDetachedListener(new MapLibreSurfaceView.OnSurfaceViewDetachedListener() {
@Override
public void onSurfaceViewDetached() {
Log.i("Mbgl-SurfaceRenderer", "SurfaceView detached; nativeReset entered");
// because the GL thread is destroyed when the view is detached from window,
// we need to ensure releasing the native renderer as well.
// This avoids releasing it only when the view is being recreated, which is already on a new GL thread,
// and leads to JNI crashes like https://github.com/mapbox/mapbox-gl-native/issues/14618
nativeReset();
Log.i("Mbgl-SurfaceRenderer", "nativeReset returned");
}
});
}