hex/ios/HEXShared
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryan Vogel 7ff7a05045
iOS: model preparation loads once, keeps moving, and survives the background (#2171)
* fix(ios): load Parakeet once and keep its preparation progress moving

On iOS 18 Hex prepares Parakeet V2 through FluidAudio. A TestFlight tester
(iPhone 14 Plus, iOS 18.6, build 56) said "Preparing model" felt stuck.

What it did before (measured on an iOS 26.2 simulator with Parakeet forced):
- AsrModels.downloadAndLoad loaded (and on a first run compiled) every model
  twice: once inside download() to check it, again in load().
- Each of those eight per-model loads reported 50% at its start and 100% at
  its end, so the bar went 0->50%, jumped to 100%, fell back to 50% and sat
  there through the encoder's compile, which takes a minute or more on an
  iPhone's Neural Engine and reports nothing.
- The download sent ~21,700 progress callbacks in 10 s, each a main-actor
  task and a SwiftUI update.
- The detail text was English-only and never shown.

Now:
- ParakeetTranscriber downloads with ModelHub.download (resumable, no load)
  and loads once with AsrModels.load. downloadAndLoad is no longer used.
- ParakeetPreparationProgress gives the download 70% of the bar, then fills
  the load on a time estimate that keeps creeping however long Core ML takes,
  never moving back and never reaching 100% before Core ML is done.
- Copy per phase, with zh-Hans: "Checking the speech model", "Downloading the
  speech model", "Optimizing for this iPhone… about a minute" (first compile),
  "Still optimizing. The first time can take a few minutes." (past twice the
  estimate), "Loading the speech model" (later launches).
- ParakeetCompileRecord remembers the iOS build Core ML last compiled for,
  so later launches say Loading and use the short estimate.
- Progress goes out at most 10 times a second (79 events for a first run).
- Home's preparing row and its handoff status line show the detail instead
  of "Preparing model…"; onboarding's Almost ready shows it beside the
  percentage.
- ParakeetLoadGuard now marks only the load, not the download, so a download
  cut off by a quit doesn't read as "closed while loading, short of memory".
- Invalid artifacts from FluidAudio map to the plain download error too.

Verified: xcodebuild test on an iOS 26.2 iPhone 14 Plus simulator (492 passed,
1 skipped); first run 467 MB in 7.8 s, load 1.6 s, relaunch 0.4 s; recordings
of home and onboarding in English and Chinese with a simulated 40 s compile.
The simulator compiles on the Mac, so real iPhone compile time is unmeasured.

* fix(ios): pick up a model download iOS cut off in the background

A preparation interrupted by going to the background could end up failed
until the person tapped Try again:
- StallWatch measured with ContinuousClock, which keeps counting while iOS
  has Hex suspended. Back in the foreground after 90 s or more, the first
  poll saw no progress for over the limit and cancelled the download with
  "The download stopped". A poll that comes back over 5 s late now counts as
  a suspension and restarts the wait.
- Preparation now holds a background task, so iOS gives a download or
  compile a few more seconds after Hex leaves the screen.
- A download failure (stall, URL error, Parakeet download error) that
  happens while Hex is in the background is tried again once when Hex is
  active again. FluidAudio resumes each file from its .partial with
  Range/If-Range, so nothing already downloaded is fetched again. A failure
  while Hex is open still waits for Try again.

FluidAudio streams through its own default-configuration URLSession data
tasks and has no hook for a background URLSession, so a download can't keep
running while Hex is suspended.

Verified: xcodebuild test on an iOS 26.2 iPhone 14 Plus simulator (492 passed,
1 skipped), including the new retry-on-return tests.
2026-11-21 10:39:38 +00:00
..
FullKeyboard iOS: German autocorrect capitalises common nouns (haus, auto, zeit) (#2169) 2026-11-21 05:30:03 -05:00
TypingLog iOS: opaque keyboard panel so stale system layers can't show through, and a nil-safe field ID (#2139) 2026-11-21 03:45:47 +00:00
AppleIntelligenceCleanupSettings.swift ios: optional Apple Intelligence transcript cleanup (experiment) (#1538) 2026-11-08 08:07:11 -05:00
AppleSpeechModule.swift iOS: dictation follows the keyboard's language, English and Spanish share one layout, and Spanish never goes to Parakeet (#2164) 2026-11-21 08:46:10 +00:00
AudioSessionControlling.swift iOS: recording leaves the hardware sample rate alone, and the keepalive backs off (#2160) 2026-11-21 07:55:13 +00:00
CleanupGuard.swift iOS: Clean up what I say keeps names, and is on by default (#2132) 2026-11-21 03:12:53 +00:00
CleanupReconstruction.swift iOS: clean up what I say with an on-device tagger (experiment) (#2023) 2026-11-20 01:29:41 +00:00
CleanupTagger.swift iOS: Clean up what I say keeps names, and is on by default (#2132) 2026-11-21 03:12:53 +00:00
CleanupTokenizer.swift iOS: clean up what I say with an on-device tagger (experiment) (#2023) 2026-11-20 01:29:41 +00:00
CustomVocabularySettings.swift ios: custom vocabulary experiment (#1547) 2026-11-08 12:15:00 -05:00
DictationCorrections.swift ios: learn dictation and typing fixes from edits (Learn how I type) (#2022) 2026-11-20 01:04:58 +00:00
DictationEditInference.swift ios: learn dictation and typing fixes from edits (Learn how I type) (#2022) 2026-11-20 01:04:58 +00:00
DictationEditTracker.swift ios: learn dictation and typing fixes from edits (Learn how I type) (#2022) 2026-11-20 01:04:58 +00:00
DictationLanguage.swift iOS: dictation follows the keyboard's language, English and Spanish share one layout, and Spanish never goes to Parakeet (#2164) 2026-11-21 08:46:10 +00:00
DictationLanguageSwitch.swift iOS: Hinglish dictation, Hindi in Latin letters (Experiment, off by default) (#2119) 2026-11-21 00:29:24 +00:00
DictationPipeline.swift iOS: text replacements without autocorrect, End with a period, and emoji and symbols on the Dictation bar (#2147) 2026-11-21 06:24:16 +00:00
DictationTranslation.swift iOS: fewer paste prompts, and a translate switch in the keyboard (#2134) 2026-11-21 03:24:58 +00:00
DotScope.swift iOS: a tap after a swiped word starts the next word, and the Metal HUD stays off the home page (#2159) 2026-11-21 07:54:19 +00:00
DotScopeShader.metal fix(ios): eliminate handoff frame stalls and add overlapping ballistic swipe throw (t1153) (#757) 2026-10-31 22:14:22 -07:00
EmptyCapture.swift iOS: fix six TestFlight tester issues (audio error, leaked error text, Live Activity, haptics, capitals, push to talk) (#2035) 2026-11-20 13:21:16 +00:00
HexTheme.swift fix(ios): eliminate handoff frame stalls and add overlapping ballistic swipe throw (t1153) (#757) 2026-10-31 22:14:22 -07:00
HinglishLexicon.swift iOS: Hinglish dictation, Hindi in Latin letters (Experiment, off by default) (#2119) 2026-11-21 00:29:24 +00:00
HinglishRomanizer.swift iOS: Hinglish dictation, Hindi in Latin letters (Experiment, off by default) (#2119) 2026-11-21 00:29:24 +00:00
HomeSwipeCue.swift iOS: a tap after a swiped word starts the next word, and the Metal HUD stays off the home page (#2159) 2026-11-21 07:54:19 +00:00
KeyboardBridge.swift iOS: a handoff to Hex can't leave the keyboard stuck, and dismissed dictations still deliver (#2163) 2026-11-21 08:31:48 +00:00
KeyboardSurface.swift iOS: a handoff to Hex can't leave the keyboard stuck, and dismissed dictations still deliver (#2163) 2026-11-21 08:31:48 +00:00
SpeechModelInstall.swift iOS: model preparation loads once, keeps moving, and survives the background (#2171) 2026-11-21 10:39:38 +00:00
SpokenCleanupRules.swift iOS: dictation styles apply in the keyboard and read differently, plus Lowercase (#2103) 2026-11-20 21:47:04 +00:00
SpokenLists.swift iOS: format dictated lists, and write out gonna and wanna (#2131) 2026-11-21 03:01:16 +00:00
TranscriptFormatter.swift iOS: text replacements without autocorrect, End with a period, and emoji and symbols on the Dictation bar (#2147) 2026-11-21 06:24:16 +00:00
UserFacingError.swift iOS: fewer paste prompts, and a translate switch in the keyboard (#2134) 2026-11-21 03:24:58 +00:00
VocabularySpelling.swift ios: custom vocabulary experiment (#1547) 2026-11-08 12:15:00 -05:00