Flutter+VSCode:运行Isolate时增删断点致应用冻结
问题相关信息
现象
- 应用启动时创建6个Isolate,创建完成后,在主线程代码中设置或增删断点,应用会出现冻结情况;需按两次运行按钮才会触发冻结(不确定该现象是否有参考价值)
- 调试时发现调用栈中Isolate的背景为灰色,与主线程样式不同,不确定该细节是否重要
环境配置
- VSCode版本:1.85.1(Universal),执行
flutter doctor时同时显示1.83.1和1.85.1版本,不确定是否正常 - Flutter环境:稳定版3.16.3
- 系统:macOS 14.2.1 23C71 darwin-arm64
- 区域设置:en-NZ
创建Isolate的代码
static Future<void> setupSurfaceIsolate(MapSurfaceProcessingData mapSurfaceProcessingData) async { int countOfIsolates = 6; for (var i = 0; i < countOfIsolates; i++) { ReceivePort myReceivePort = ReceivePort(); /// Spawn an isolate, passing my receivePort sendPort Isolate.spawn<SendPort>(calculateUsingIsolate, myReceivePort.sendPort); // get the isolate send port, this is used to establish the connection, so that I can get the sendPort Future<dynamic> futurePort = myReceivePort.first; futurePort.then((value) { mapSurfaceProcessingData.isolateMap.add(value); }); } }
内容的提问来源于stack exchange,提问作者Paul Cardno
相关产品推荐
相关产品推荐

