Skip to content

Commit b6ea537

Browse files
dzinadgithub-actions[bot]
authored andcommitted
fix double OnSnapshotReady listener invocation
GitOrigin-RevId: e4ca3efb5c4fc5d03b8842233b8449cfa6ae17e4
1 parent e52e21a commit b6ea537

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Mapbox welcomes participation and contributions from everyone.
55
> **16 KB Page Size Support:** Starting with version 11.7.0 and 10.19.0, **NDK 27 is supported** with dedicated artifacts that include [support for 16 KB page sizes](https://developer.android.com/guide/practices/page-sizes). If your app does not require 16 KB page size support, you can keep using our default artifacts without `-ndk27` suffix. For more information about our NDK support, see https://docs.mapbox.com/android/maps/guides/#ndk-support
66
77
# main
8+
## Bug fixes 🐞
9+
* Fix an issue where `MapView#snapshot` listener was invoked twice when the map was not ready.
810

911
# 11.16.0-beta.1 September 23, 2025
1012

maps-sdk/src/main/java/com/mapbox/maps/renderer/MapboxRenderer.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,15 @@ internal abstract class MapboxRenderer(mapName: String) : DelegatingMapClient {
182182
if (!readyForSnapshot.get()) {
183183
logE(TAG, "Could not take map snapshot because map is not ready yet.")
184184
listener.onSnapshotReady(null)
185-
}
186-
val legacyMode = snapshotLegacyModeEnabled
187-
renderThread.queueRenderEvent(
188-
RenderEvent(
189-
runnable = { listener.onSnapshotReady(performSnapshot(legacyMode)) },
190-
needRender = true,
185+
} else {
186+
val legacyMode = snapshotLegacyModeEnabled
187+
renderThread.queueRenderEvent(
188+
RenderEvent(
189+
runnable = { listener.onSnapshotReady(performSnapshot(legacyMode)) },
190+
needRender = true,
191+
)
191192
)
192-
)
193+
}
193194
}
194195

195196
@AnyThread

maps-sdk/src/test/java/com/mapbox/maps/renderer/MapboxRendererTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ internal abstract class MapboxRendererTest {
257257
}
258258
val event = slot<RenderEvent>()
259259
every { renderThread.queueRenderEvent(capture(event)) } answers {
260-
handler.post(event.captured.runnable!!)
260+
throw AssertionError("Render event should not be queued when not ready for snapshot")
261261
}
262262
mapboxRenderer.pixelReader = pixelReader
263263
mapboxRenderer.readyForSnapshot = AtomicBoolean(false)

0 commit comments

Comments
 (0)