Skip to content

[codex] 修复 Android 录音 SIGILL 崩溃#98

Merged
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/fix-sherpa-onnx-sigill
May 15, 2026
Merged

[codex] 修复 Android 录音 SIGILL 崩溃#98
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/fix-sherpa-onnx-sigill

Conversation

@utopiafar
Copy link
Copy Markdown
Collaborator

背景 / 根因

Issue #29 在 Android 真机点击录音后会发生 native SIGILL 崩溃。排查日志和反汇编显示:

  • 录音权限、模型下载和 VAD 初始化都已经通过;崩溃发生在第一帧音频进入 VoiceActivityDetector.acceptWaveform() 时。
  • crash 栈落在 libonnxruntime.so,旧包 sherpa_onnx_android 1.12.36 携带的 ORT 为 1.23.2
  • 崩溃指令位于 ORT/KleidiAI SME2 路径;目标设备暴露 SME,但不支持 sme2,因此执行 SME2 指令触发 SIGILL

这更像是上游 native runtime 的 CPU feature dispatch 兼容问题,不是 Dart 侧异常、权限问题,也不是 SenseVoice 模型文件损坏。

修复方案

  • sherpa_onnx^1.12.36 精确升级到 1.13.2
    • 1.12.37/#3494 将 Android ORT 升到 1.24.3
    • 1.12.38/#3501 继续更新 ORT 版本线。
    • 1.12.40/#3522 拆分 Android ABI 包,但该版本有 BuildConfig is defined multiple times 的 release 构建问题(#3557)。
    • 1.13.0/#3559 修复 ABI split 后的 Android namespace 冲突,所以这里直接落到 1.13.2,避免卡在 1.12.40 的构建坑。
  • 保留精确 pin,避免 ^ 后续自动跳版本扩大风险。
  • 补充录音启动、streaming transcriber 初始化、PCM stream 开始,以及首个 VAD window 的日志,后续排查不再依赖截图猜阶段。

兼容性检查

  • Dart API 对比:sherpa_onnx 1.12.36 与 1.13.2 的 lib/ 目录逐文件一致;本项目使用的 VoiceActivityDetectorOfflineRecognizerreadWave 等 API 没有签名变化。
  • native symbol 对比:新旧 libsherpa-onnx-c-api.so 都导出当前使用的 VAD / OfflineRecognizer / ReadWave 相关 C API。
  • Android ABI 打包:arm64 / armeabi-v7a / x86_64 split APK 和 debug AAB 均能正确包含对应 ABI 的 sherpa/ORT so。
  • iOS:sherpa_onnx_ios lock 同步到 1.13.2;podspec 除版本号外无接口性变化。

验证

  • flutter pub get --offline
  • flutter analyze --no-pub lib/data/services/streaming_transcriber.dart lib/ui/main_screen/widgets/input_sheet.dart lib/main.dart
    • 仅剩 lib/main.dart 既有 16 个 info 级 lint,无新增 error。
  • flutter test --no-pub test/ui/main_screen/widgets/input_sheet_test.dart
  • flutter build apk --debug --flavor globalDev --target-platform android-arm64 --split-per-abi --no-pub
  • 额外兼容性 smoke:
    • flutter build apk --debug --flavor globalDev --target-platform android-arm --split-per-abi --no-pub
    • flutter build apk --debug --flavor globalDev --target-platform android-x64 --split-per-abi --no-pub
    • flutter build apk --debug --flavor globalDev --no-pub
    • flutter build appbundle --debug --flavor globalDev --no-pub
    • flutter build ios --debug --flavor global --no-codesign --no-pub

已知情况

  • 当前环境没有再次识别到真机,因此最终录音按钮 smoke test 还需要接上设备后补跑。
  • release APK 构建目前被既有 GeneratedPluginRegistrantflutter_native_splash Java 编译问题挡住,未作为本 PR 的通过项。

Fixes #29

@utopiafar utopiafar marked this pull request as ready for review May 15, 2026 11:18
@utopiafar utopiafar merged commit 3ba509e into memex-lab:main May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Redmi K90 Pro Max 语音识别 native crash

1 participant