-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Icon blinks zooming in/out with PointAnnotationGroup/Compose #2332
Comments
I have the same issue on 11.3.0. The Icons even blink sometimes when not zooming, but less frequently. |
The blinking with no zooming ongoing can be reproduced by applying this diff index 2b4d49016..1633def9e 100644
--- a/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/annotation/PointAnnotationClusterActivity.kt
+++ b/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/annotation/PointAnnotationClusterActivity.kt
@@ -2,6 +2,7 @@ package com.mapbox.maps.compose.testapp.examples.annotation
import android.graphics.Color
import android.os.Bundle
+import android.util.Log
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
@@ -35,6 +36,7 @@ import com.mapbox.maps.plugin.annotation.ClusterOptions
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.delay
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
@@ -54,6 +56,8 @@ public class PointAnnotationClusterActivity : ComponentActivity() {
mutableStateOf<List<Point>>(listOf())
}
+ var counter by remember { mutableStateOf(0) }
+
MapboxMapComposeTheme {
ExampleScaffold {
MapboxMap(
@@ -68,6 +72,7 @@ public class PointAnnotationClusterActivity : ComponentActivity() {
MapStyle(style = Style.LIGHT)
}
) {
+ Log.d("TAG", "counter: $counter")
PointAnnotationGroup(
annotations = points.map {
PointAnnotationOptions()
@@ -99,6 +104,14 @@ public class PointAnnotationClusterActivity : ComponentActivity() {
}
)
}
+ LaunchedEffect(Unit) {
+ withContext(Dispatchers.IO) {
+ while (true) {
+ counter++
+ delay(3000)
+ }
+ }
+ }
LaunchedEffect(Unit) {
withContext(Dispatchers.IO) {
points = loadData() It basically just forces recompose every 3 seconds |
* Expose MapInitOptions.mapName property * PR fixes
Hey @kevinMoonware, the blink of view annotations is likely due to recomposition of your
The recomposition of the parent composable will trigger the recalculation of the annotations, and since new annotation option instances are created, it will trigger the annotations being removed and added again. To fix this issue, you can extract the calculation logic to a remember mutable state, so that new annotation options wouldn't be created each time |
If the points change they need to be recomposed. Remembering the annotation options will prevent that. |
Environment
Observed behavior and steps to reproduce
Icon blinks when zoom in/out. The blinking intensifies when zooming out and the icons are getting closer to each other. Blinking appears much less often when there are few than 3 icons visible within the map region (but it does still happen sometimes).
Please see video capture here:
https://youtube.com/shorts/es0iWngndEo?feature=share
Expected behavior
Icon(s) do not blink, or only blink when clustering ops are happening. Blinking should not happen during typical zoom in/out operation when zoom level is large enough that clustering is not a factor.
Notes / preliminary analysis
Additional links and references
The text was updated successfully, but these errors were encountered: