Repository navigation
Commit 2ad63ee
authored
fix(dart-sdk): deliver the in-flight Whisper batch on stop (#22395)
## What changed and why
Fixes #22393
`WhisperTranscriber` in the Dart device SDK (`sdks/device/dart`) hands
each full batch to the injected runner without awaiting it
(`unawaited(_flush())`), and `_flush` drops the runner's result when it
resolves after `stop()` has set `_stopped`. `stop()` only transcribes
the buffered tail. So stopping while a batch is being transcribed loses
that batch's transcript, up to `batchSeconds` of audio (5 s by default),
and `stop()` returns before the batch finishes. The TypeScript and React
Native SDKs had the same stopped-flag check; #20407 and #13619 fixed it
there, and #21577 is the Python counterpart.
- Batches now run one at a time in input order. Each waits for the
previous one to settle, including after a failure.
- `stop()` queues the buffered tail behind the batches already accepted.
It completes after invoking the transcript callbacks. Repeated calls
share the same completion, including any tail failure. The transcriber
ignores PCM appended after stopping begins.
- Background runner failures still reach the caller's Dart zone and
allow later batches to run. A tail failure reaches the caller through
`stop()`.
- The refreshed branch uses the Dart Device SDK test workflow and CI
budget already on main from #22347.
## Product invariants affected
none
## How it was verified
- Ran the contributor's original two regression cases against current
main `dea64c4b` with Flutter 3.44.5. Both failed on the missing
in-flight callback, once with a buffered tail and once at an exact batch
boundary.
- Ran `flutter test --no-pub --reporter expanded` in `sdks/device/dart`.
All 25 package tests passed, including the four stop regressions. The
tests use the public SDK and controlled runners with synthetic PCM.
- Compared SDK analyzer output on the two versions using `flutter
analyze --no-pub --no-fatal-infos --no-fatal-warnings`. Both report the
same four pre-existing diagnostics and zero errors.
## Tests
`sdks/device/dart/test/whisper_stop_test.dart` covers queued and
in-flight batches followed by the buffered tail, an exact batch
boundary, ignored PCM after stop, repeated stop with a tail failure, and
a background failure followed by a successful tail.
## UI evidence
UI-Evidence: none -- Dart device SDK library change with no UI; the
regression tests above cover the behaviour
## Failure class (fixes)
Failure-Class: new
## Failure-class transition narrative
New class `FC-stop-discards-in-flight-batch` in the
`work-bounded-resumable` family. The same stopped-flag check on an
in-flight batch shipped in the TypeScript (#12964), React Native
(#13618), Python (#21577) and Dart device SDKs.
- Violated contract: a batching transcriber must deliver the result of
every batch it accepted before stop, including one whose runner call is
still in flight when stop is called.
- Canonical guard: batches run one at a time in input order, every
result is delivered, new input stops at the start of `stop()`, and every
caller waits on the same drain. `whisper_stop_test.dart` holds the
runner's result pending across `stop()`.
- Evidence: the merged TypeScript and React Native fixes #20407 and
#13619, and this PR.4 files changed
Lines changed: 164 additions & 10 deletions
File tree
- .github/failure-classes
- sdks/device/dart
- lib/stt
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | | - | |
| 227 | + | |
| 228 | + | |
225 | 229 | | |
226 | 230 | | |
227 | 231 | | |
228 | | - | |
| 232 | + | |
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
236 | | - | |
| 240 | + | |
237 | 241 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 258 | + | |
248 | 259 | | |
249 | 260 | | |
250 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
0 commit comments