最新版本(windows 1.52)的flutter在启动的时候默认开启了service-auth-codes功能,导致了查看timeline页面一直显示空白;同时使用 flutter screenshot --type=skia --verbose --observatory-port=xxxxx抓图,发现无法连接127.0.0.1:xxxxx,报错如下
‘http://127.0.0.1:xxxxx/ws#’ was not upgraded to websocket
[ +5 ms] This was attempt #3. Will retry in 0:00:00.400000
而运行应用的时候可以看到地址是127.0.0.1:xxxx/auth-code/,怀疑新版本开启此功能导致;而flutter timeline、screenshot默认采用老的方式连接本地server,导致抓图失败
查看命令选项暂时没有直接关闭此功能选项,无意间看代码,发现有这个选项
https://github.com/flutter/engine/blob/master/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
line 30
public static final String ARG_KEY_DISABLE_SERVICE_AUTH_CODES = “disable-service-auth-codes”;
public static final String ARG_DISABLE_SERVICE_AUTH_CODES = “–disable-service-auth-codes”;
尝试用以下命令启动应用就可以了
flutter run --profile --trace-skia -v --observatory-port=xxxxx –disable-service-auth-codes
然后再运行
flutter screenshot --type=skia --verbose --observatory-port=xxxxx可正常生成skp文件
针对Flutter最新版本(windows1.52)中默认开启的service-auth-codes功能导致的timeline页面空白及截图失败问题,本文介绍了解决方案。通过在启动命令中加入–disable-service-auth-codes参数,成功解决了连接本地server的问题,使得flutterscreenshot能够正常运行并生成skp文件。
2566

被折叠的 条评论
为什么被折叠?



