mapbox / mapbox/mapbox-maps-flutter
Calling easeTo may be creating a memory leak
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Dart
- Estrellas
- 380
- Forks
- 204
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I have a handful of buttons on top of my Mapbox map that perform various functions with the map. One of them is a "3D view toggle". This function just calls easeTo. Im getting some strange behaviour after interacting with this button that I dont get at all if I dont touch it. Ive attached the code were using as well as a video of what this issue looks like.
Mapbox SDK Version: Seems to be all
Testing on iOS
```
void _togglePitch() {
// Prevent multiple simultaneous pitch changes
if (_isEasingInProgress) {
return;
}
// Ensures mapboxMap is not null before attempting to use it
if (mapboxMap == null) {
debugPrint('MapboxMap is not initialized');
return;
}
try {
// Set flag to prevent additional calls
setState(() {
_isEasingInProgress = true;
is3D = !is3D;
});
mapboxMap!.easeTo(
CameraOptions(pitch: is3D ? 75 : 0),
MapAnimationOptions(duration: 1000),
).then((_) {
// Reset the flag when animation is complete
setState(() {
_isEasingInProgress = false;
});
}).catchError((error) {
debugPrint('Error toggling pitch: $error');
setState(() {
is3D = !is3D;
_isEasingInProgress = false;
});
});
} catch (e) {
debugPrint('Error toggling pitch: $e');
// Optionally, reverts the state if the pitch change fails
setState(() {
is3D = !is3D;
_isEasingInProgress = false;
});
}
}
```
https://github.com/user-attachments/assets/153d13f6-0723-4a1c-b634-0aaa5388c295

Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la función _togglePitch proporcionada y su llamada a easeTo, y luego reproduce el comportamiento reportado en iOS usando el código y el vídeo adjuntos. Compara el comportamiento con y sin el interruptor 3D en las versiones de SDK indicadas; se considerará terminado cuando se explique el comportamiento de la memoria y se documente una reproducción mínima o la causa confirmada.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- dart, flutter
- Área
- mobile-dev
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100