Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

fix(asr): stop the error path from calling itself

booboosui9a983d051c94
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36e9b3e..2997210 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -108,6 +108,18 @@ build time would close this hole; it is not implemented yet.)
to be. The rule to carry forward is that this file tracks the addresses actually in use — adding a
line is part of pointing the app at plain HTTP, and removing it is part of moving away.
+### Fixed
+
+- **A failed voice turn crashed the app with `StackOverflowError` instead of reporting the failure.**
+ `AsrController`'s listener implements `onError(msg)`, and its body called `onError(msg)` — written
+ meaning the constructor's `(String) -> Unit` callback that routes the message to the owner. Kotlin
+ resolves an unqualified call to the nearest scope first, so the line called *itself*: one recognizer
+ error became infinite recursion until the stack ran out (`stack size 1039KB`, thousands of frames of
+ `AsrController.kt:152`). Any 火山 failure — a dead network, an expired token, a rejected handshake —
+ took the whole process down, which is the opposite of what the callback is for. Now qualified
+ `[email protected](msg)`. The listener's three other callbacks are unaffected: none of them
+ shares a name with an outer member.
+
### Changed
- **The APK went from ~39 MB to ~8 MB.** Two causes, both structural rather than a matter of
diff --git a/app/src/main/java/net/kuafuai/andee/asr/AsrController.kt b/app/src/main/java/net/kuafuai/andee/asr/AsrController.kt
index 7b57be4..337d1a7 100644
--- a/app/src/main/java/net/kuafuai/andee/asr/AsrController.kt
+++ b/app/src/main/java/net/kuafuai/andee/asr/AsrController.kt
@@ -149,7 +149,11 @@ class AsrController(
// up as a card and as a red row, and "听着…" is no longer true.
window.clearSubtitle()
window.setState(FloatingWindowUi.State.ERROR)
- onError(msg)
+ // Qualified on purpose: this block overrides the listener's own
+ // onError(msg), so a bare `onError(msg)` would resolve to *this*
+ // function and recurse until the stack blows. The intent is the
+ // constructor's callback — hand the failure to the owner.
executor.execute { runCatching { stopImpl() } }
}