Skip to content

Commit dd48946

Browse files
fix Android Vulkan instrumentation tests (#4091)
1 parent d54f84a commit dd48946

7 files changed

Lines changed: 18 additions & 24 deletions

File tree

include/mbgl/vulkan/renderer_backend.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
2020
#include "vk_mem_alloc.h"
2121

22-
#ifndef NDEBUG
22+
#if !defined(NDEBUG) && !defined(__ANDROID__)
2323
#define ENABLE_VULKAN_VALIDATION
2424
// #define ENABLE_VULKAN_GPU_ASSISTED_VALIDATION
2525
// #define ENABLE_VMA_DEBUG
@@ -61,7 +61,7 @@ class RendererBackend : public gfx::RendererBackend {
6161
if (!debugUtilsEnabled) return;
6262
const uint64_t handle = reinterpret_cast<uint64_t>(static_cast<typename T::CType>(object));
6363
device->setDebugUtilsObjectNameEXT(vk::DebugUtilsObjectNameInfoEXT()
64-
.setObjectType(object.objectType)
64+
.setObjectType(T::objectType)
6565
.setObjectHandle(handle)
6666
.setPObjectName(name.c_str()),
6767
dispatcher);

platform/android/MapLibreAndroid/src/cpp/map_renderer.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,8 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) {
196196

197197
void MapRenderer::resetRenderer() {
198198
renderer.reset();
199-
#if MLN_RENDER_BACKEND_OPENGL
200-
// GL requires the context managed by the java surface for cleanup
201-
// Vulkan resources can be released on any thread (finalizer in this case)
202199
backend.reset();
203-
#endif
200+
window.reset();
204201
swapBehaviorFlush = false;
205202
}
206203

@@ -316,7 +313,6 @@ void MapRenderer::onRendererReset(JNIEnv&) {
316313
// needs to be called on GL thread
317314
void MapRenderer::onSurfaceDestroyed(JNIEnv&) {
318315
resetRenderer();
319-
window.reset();
320316
}
321317

322318
void MapRenderer::setSwapBehaviorFlush(JNIEnv&, jboolean flush) {

platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/maps/renderer/textureview/TextureViewRenderThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
8585
this.requestRender = false;
8686
lock.notifyAll();
8787

88-
while (this.hasNativeSurface) {
88+
while (this.hasNativeSurface && !this.exited) {
8989
try {
9090
lock.wait();
9191
} catch (InterruptedException ex) {

platform/android/MapLibreAndroid/src/vulkan/java/org/maplibre/android/maps/renderer/textureview/VulkanTextureViewRenderThread.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ public VulkanTextureViewRenderThread(@NonNull TextureView textureView, @NonNull
1616
}
1717

1818
void cleanup() {
19-
if (surface == null) {
20-
return;
19+
if (surface != null) {
20+
mapRenderer.onSurfaceDestroyed();
21+
surface.release();
22+
surface = null;
2123
}
2224

23-
mapRenderer.onSurfaceDestroyed();
24-
surface.release();
25-
surface = null;
26-
2725
hasNativeSurface = false;
2826
}
2927

@@ -56,14 +54,17 @@ public void run() {
5654
}
5755

5856
if (this.destroySurface) {
59-
surface = null;
6057
destroySurface = true;
58+
if (surface != null) {
59+
surface.release();
60+
surface = null;
61+
}
62+
6163
this.destroySurface = false;
6264
break;
6365
}
6466

65-
if (surfaceTexture != null && !paused && requestRender
66-
&& (surface == null || this.sizeChanged)) {
67+
if (surfaceTexture != null && !paused && requestRender) {
6768

6869
w = width;
6970
h = height;
@@ -87,10 +88,6 @@ public void run() {
8788
break;
8889
}
8990

90-
if (requestRender && !paused) {
91-
break;
92-
}
93-
9491
// Wait until needed
9592
lock.wait();
9693

@@ -113,11 +110,11 @@ public void run() {
113110

114111
if (destroySurface) {
115112
mapRenderer.onSurfaceDestroyed();
116-
destroySurface = false;
117113
synchronized (lock) {
118114
this.hasNativeSurface = false;
119115
lock.notifyAll();
120116
}
117+
destroySurface = false;
121118
continue;
122119
}
123120

platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/MapLibreApplication.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ open class MapLibreApplication : MultiDexApplication() {
4949
StrictMode.setVmPolicy(
5050
VmPolicy.Builder()
5151
.detectLeakedSqlLiteObjects()
52+
.detectLeakedClosableObjects()
5253
.penaltyLog()
5354
.penaltyDeath()
5455
.build()

platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/fragment/ViewPagerActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ViewPagerActivity : AppCompatActivity() {
4848

4949
override fun getItem(position: Int): androidx.fragment.app.Fragment {
5050
val options = MapLibreMapOptions.createFromAttributes(context)
51-
options.textureMode(true)
51+
options.textureMode(false)
5252
options.camera(
5353
CameraPosition.Builder()
5454
.zoom(3.0)

platform/android/buildSrc/src/main/kotlin/maplibre.download-vulkan-validation.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.net.URL
1818
*/
1919

2020
// Define the validation layer version, with a default value.
21-
var vvlVersion = "1.4.313.0"
21+
var vvlVersion = "1.4.341.0"
2222
if (extra.has("vvl_version")) {
2323
vvlVersion = extra["vvl_version"] as String
2424
}

0 commit comments

Comments
 (0)