Skip to content

Commit 5fb2599

Browse files
authored
Port widget related fixes from v11 (#2160)
1 parent 6c62360 commit 5fb2599

File tree

4 files changed

+180
-120
lines changed

4 files changed

+180
-120
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Mapbox welcomes participation and contributions from everyone.
44

5+
# 10.16.3
6+
## Bug fixes 🐞
7+
* Fix widgets flickering due to race condition if they are animated.
8+
* Fix widgets not showing on some zoom levels.
9+
* Fix map being black when using widgets (e.g. when `MapDebugOptions.TILE_BORDERS` option is enabled).
510

611
# 10.16.2 November 08, 2023
712
## Bug fixes 🐞

app/src/main/java/com/mapbox/maps/testapp/examples/SurfaceActivity.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class SurfaceActivity : AppCompatActivity(), SurfaceHolder.Callback {
4545
mapInitOptions,
4646
)
4747

48+
// Show tile borders to make sure widgets are still rendered as expected
49+
mapSurface.getMapboxMap().setDebug(
50+
listOf(MapDebugOptions.TILE_BORDERS),
51+
enabled = true
52+
)
53+
4854
// Load a map style
4955
mapSurface.getMapboxMap().loadStyleUri(Style.MAPBOX_STREETS)
5056

sdk/src/main/java/com/mapbox/maps/renderer/MapboxRenderThread.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,25 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
289289
}
290290
}
291291

292+
/**
293+
* Resetting OpenGL state to make sure widget textures are rendered on top of the map.
294+
*/
295+
private fun resetGlState() {
296+
// using at least MapDebugOptions.TILE_BORDERS and perhaps in other situations
297+
// rending engine may change the blend function; so we explicitly reset it to needed values
298+
GLES20.glEnable(GLES20.GL_BLEND)
299+
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA)
300+
GLES20.glBlendEquation(GLES20.GL_FUNC_ADD)
301+
302+
// explicitly disable stencil and depth because otherwise widgets may be rendered
303+
// behind the map tiles in some scenarios
304+
GLES20.glDisable(GLES20.GL_STENCIL_TEST)
305+
GLES20.glDisable(GLES20.GL_DEPTH_TEST)
306+
GLES20.glUseProgram(0)
307+
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0)
308+
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0)
309+
}
310+
292311
private fun draw(frameTimeNanos: Long) {
293312
if (!fpsManager.preRender(frameTimeNanos, renderThreadRecorder?.recording == true)) {
294313
// when we have FPS limited and desire to skip core render - we must schedule new draw call
@@ -303,6 +322,7 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
303322
}
304323

305324
nativeRender()
325+
resetGlState()
306326

307327
if (widgetRenderer.hasTexture()) {
308328
widgetTextureRenderer.render(widgetRenderer.getTexture())

0 commit comments

Comments
 (0)