Repository navigation
What happened?On Android, the MapLibre map stayed invisible (blank/black hole) until a touch or scroll forced a redraw when inside a Scaffold. It seems that maplibre-compose 0.15.0's default render mode (RenderMode.Surface) puts the map in a SurfaceView behind the window, with a transparent hole punched into the Compose view. The SurfaceFlinger sync between that hole and the SurfaceView's first frame doesn't happen until an external redraw occurs. I switched to RenderMode.Texture (a TextureView, composited normally, no z-order hack): RenderOptions(
preferredRenderMode = RenderOptions.RenderMode.Texture,
)not sure what to do more, but I wanted to report it. Maybe there is something to do in the lib. Others can be interested in the workaround. Affected Platforms
Platform VersionAndroid Library Version0.15.0 Sample Code// |
Replies: 4 comments 6 replies
This was true in all previous versions as well. Could you share more of the reproduction? The demo app does not reproduce this. |
|
Well, that took quite some tries, but I have a minimal reproduction: It happens when we have a combination of :
package net.libresky.app.map
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.screen.Screen
import kotlinx.coroutines.delay
import org.maplibre.compose.camera.CameraPosition
import org.maplibre.compose.camera.rememberCameraState
import org.maplibre.compose.map.MaplibreMap
import org.maplibre.compose.overlay.MapOverlay
import org.maplibre.compose.style.BaseStyle
import org.maplibre.spatialk.geojson.Position
import kotlin.time.Duration.Companion.seconds
private val PARIS = CameraPosition(
target = Position(longitude = 2.3522, latitude = 48.8566),
zoom = 11.0,
)
class TestMapScreen : Screen {
@Composable
override fun Content() {
TestMapContent()
}
}
@Composable
private fun TestMapContent() {
var loading by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
delay(1.seconds)
loading = false
}
if (loading) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(text = "Loading")
}
return
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
) {
MaplibreMap(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp)),
baseStyle = BaseStyle.Uri(POSITRON_STYLE_URL),
cameraState = rememberCameraState(firstPosition = PARIS),
overlay = MapOverlay.None,
)
}
}(composeMultiplatform = "1.12.0") |
|
My triage agent was unable to reproduce with your exact snippet. Test setup:
issue1121-v0150-voyager-scaffold-api34-final.mp4 |
|
I can reproduce it consistently on device & simulator. But, weirdly enough, not when recording the screen natively within Android. Here is on simulator, recorded externally from MacOS: Enregistrement.de.l.ecran.2026-08-28.a.02.06.07.mp4 |
filed as #1150, will take a look