# 稳定性问题场景案例

一、应用发布邀请测试或正式上架启动闪退问题场景分析

1. 故障现场描述

   项目应用本地启动运行正常无误，发布邀请测试或正式上架启动闪退。

2. 报错堆栈信息

   ```
   Device info:HUAWEI Mate 60
   Build info:BRA-AL00 5.0.0.150(SP8C00E150R4P30)
   Fingerprint:9e0ffabdb981862b88d947a5956da3ca583c6a76a88b191ffb4d3ced7e9d7b78
   Module name:com.example.flutter
   Version:1.0.1
   VersionCode:1000001
   PreInstalled:No
   Foreground:Yes
   Timestamp:2025-07-11 11:14:20.185
   Pid:4358
   Uid:20020018
   Process name:com.example.flutter
   Process life time:11s
   Reason:Signal:SIGABRT(SI_TKILL)@0x01317b3200001106 from:4358:20020018
   LastFatalMessage:../../third_party/dart/runtime/vm/virtual_memory_posix.cc: 74: error: mmap failed: 22 (Invalid argument)
   Fault thread info:
   Tid:4358, Name:ths.wifi_camera
   #00 pc 0000000000199e5c /system/lib/ld-musl-aarch64.so.1(raise+228)(c66b0063d30004b77342b1dde06f68b1)
   #01 pc 0000000000146f8c /system/lib/ld-musl-aarch64.so.1(abort+20)(c66b0063d30004b77342b1dde06f68b1)
   #02 pc 0000000003d1271c /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #03 pc 0000000003f0c98c /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #04 pc 0000000003f0c7e8 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #05 pc 0000000003f29038 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #06 pc 0000000003f29cd0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #07 pc 0000000003f2a418 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #08 pc 0000000003f2129c /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #09 pc 0000000003e002a0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #10 pc 0000000003e2e1a8 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #11 pc 0000000003e2e4b0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #12 pc 0000000003eece5c /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #13 pc 0000000003eecc28 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #14 pc 0000000003d98974 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #15 pc 0000000003d98bc0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #16 pc 0000000003c915a0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #17 pc 0000000003c8cba4 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #18 pc 0000000003c8c0c0 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #19 pc 0000000003c92154 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #20 pc 0000000003ab02fc /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #21 pc 0000000003ab042c /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #22 pc 0000000002174c70 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #23 pc 000000000211f640 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #24 pc 0000000002113074 /data/storage/el1/bundle/libs/arm64/libflutter.so(fedfd138e5142725b25cd00c996876ca4c0ef7c6)
   #25 pc 000000000003e9e4 /system/lib64/platformsdk/libace_napi.z.so(panda::JSValueRef ArkNativeFunctionCallBack<true>(panda::JsiRuntimeCallInfo*)+212)(85e70f1f5cf0e81468ec141fc2f4922c)
   #26 pc 0000000000404b2c /system/lib64/module/arkcompiler/stub.an(RTStub_PushCallArgsAndDispatchNative+40)
   #27 at attachToNative (entry|@ohos/flutter_ohos|1.0.0-e7a98130f5|src/main/ets/embedding/engine/FlutterNapi.ts:87:1)
   #28 at attachToNapi (entry|@ohos/flutter_ohos|1.0.0-e7a98130f5|src/main/ets/embedding/engine/FlutterEngine.ts:119:1)
   #29 at init (entry|@ohos/flutter_ohos|1.0.0-e7a98130f5|src/main/ets/embedding/engine/FlutterEngine.ts:109:1)
   ```

   

3. 问题场景分析

   【问题定位】 
   - 从应用市场反馈的报错日志中识别出关键词SI_TKILL，raise+228，abort+20，这些都是断言日志，表示flutter.har是使用的debug版本，正式发布的包应该使用release编译，日志中不应该出现断言。
   - 关键字第27行attachToNative。存在安全方面的影响，上线的release版本应用禁用了JIT能力（c++中申请可执行匿名内存的能力），影响到了flutter应用，不再支持申请有执行权限的匿名内存，导致debug版本运行闪退。
   - release包体积会比debug包体积小很多，可以看下提审的app包体积。

   【原因分析】 
   debug编译打包的flutter应用没有匿名内存的可执行权限，导致启动闪退。

4. 解决方案

   发布的正式包需要使用 release 编译。编译命令：` flutter build hap --release`。



二、未使用最新flutter代码应用启动闪退问题场景分析

1. 故障现场描述

   使用旧版本 flutter 代码，应用启动后闪退。

2. 报错堆栈信息

   ```
   HiLog :
   ...
   FlutterEngine : Thread :385496703040 [FATAL:flutter/runtime/dart_vm_initializer.cc(89)]
   Error while initializing the Dart VM: Wrong full snapshot version, expected '25523e38d22932934b1f691de39b5c14' found 'd20albe77c3d3c41b2a5accaeelce549'
   FlutterEngine: FML KILL PROCESS 
   ...
   ```

   

3. 问题场景分析
   【问题定位】
   出现`Error while initializing the Dart VM: Wrong full snapshot version`问题，通过删除缓存，重新编译操作后，仍未解决问题，应该和版本适配有关。
   【原因分析】
   未使用最新版本代码。

4. 解决方案

   1. 设置环境变量`export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com`；
   2. 删除`/bin/cache`目录下的缓存；
   3. 拉取最新代码，执行`flutter clean`，清除项目编译缓存；
   4. 运行`flutter run -d $DEVICE(设备id) --debug`。