Fix Android backend cleanup (#3681)
This commit is contained in:
@@ -37,7 +37,13 @@ AndroidGLRendererBackend::AndroidGLRendererBackend()
|
||||
: gl::RendererBackend(gfx::ContextMode::Unique),
|
||||
mbgl::gfx::Renderable({64, 64}, std::make_unique<AndroidGLRenderableResource>(*this)) {}
|
||||
|
||||
AndroidGLRendererBackend::~AndroidGLRendererBackend() = default;
|
||||
AndroidGLRendererBackend::~AndroidGLRendererBackend() {
|
||||
#ifndef NDEBUG
|
||||
if (context && static_cast<gl::Context&>(*context).getCleanupOnDestruction()) {
|
||||
assert(eglGetCurrentContext() != EGL_NO_CONTEXT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gl::ProcAddress AndroidGLRendererBackend::getExtensionFunctionPointer(const char* name) {
|
||||
assert(gfx::BackendScope::exists());
|
||||
|
||||
@@ -196,6 +196,11 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) {
|
||||
|
||||
void MapRenderer::resetRenderer() {
|
||||
renderer.reset();
|
||||
#if MLN_RENDER_BACKEND_OPENGL
|
||||
// GL requires the context managed by the java surface for cleanup
|
||||
// Vulkan resources can be released on any thread (finalizer in this case)
|
||||
backend.reset();
|
||||
#endif
|
||||
swapBehaviorFlush = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -272,9 +272,7 @@ public class MapLibreGLSurfaceView extends MapLibreSurfaceView {
|
||||
|
||||
private void destroySurfaceImp() {
|
||||
if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
|
||||
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
|
||||
EGL10.EGL_NO_SURFACE,
|
||||
EGL10.EGL_NO_CONTEXT);
|
||||
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, mEglContext);
|
||||
MapLibreGLSurfaceView view = mGLSurfaceViewWeakRef.get();
|
||||
if (view != null) {
|
||||
view.eglWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay, mEglSurface);
|
||||
@@ -284,6 +282,13 @@ public class MapLibreGLSurfaceView extends MapLibreSurfaceView {
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
if (mEglDisplay != null) {
|
||||
mEgl.eglMakeCurrent(mEglDisplay,
|
||||
EGL10.EGL_NO_SURFACE,
|
||||
EGL10.EGL_NO_SURFACE,
|
||||
EGL10.EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
if (mEglContext != null) {
|
||||
MapLibreGLSurfaceView view = mGLSurfaceViewWeakRef.get();
|
||||
if (view != null) {
|
||||
|
||||
Reference in New Issue
Block a user