flutter新版本无法使用timeline及screenshot进行性能分析问题
flutter screenshot --type=skia --verbose --observatory-port=xxxx失效问题最新版本的flutter在启动的时候默认开启了service-auth-codes功能,开启此功能后访问调试网页不能直接用127.0.0.1:xxxx必须使用127.0.0.1:xxxx/auth-code/才可以;而flutter screenshot默认采用.
最新版本(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文件
更多推荐
所有评论(0)