mapbox / mapbox/mapbox-maps-flutter
Calling easeTo may be creating a memory leak
未关闭
还没有人认领这个 Issue。
- 主要语言
- Dart
- 星标
- 380
- 派生
- 204
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从提供的 _togglePitch 函数及其 easeTo 调用开始,然后使用附带的代码和视频在 iOS 上重现所报告的行为。在指定的 SDK 版本中比较启用和不启用 3D 开关时的行为;当内存行为得到解释,并记录了最小复现或已确认的原因后,即可完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- dart, flutter
- 领域
- mobile-dev
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100