hex/ios/HEXMobileTests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryan Vogel 5552df8a3f
iOS: keep a failed recorder alive until its audio queue stops calling back (#2133)
When the keyboard can't dictate itself (keyboardNeedsHex) its Hex key opens
Hex, which records with AVAudioRecorder. If the microphone fails there (no
input in the simulator, or another app holding it), record() returns false
after AudioQueueStart fails, and the recorder stops and disposes its queue
from inside the queue's own callback, asynchronously. beginCapture threw and
freed the recorder right away, while restoreAudioAfterCapture restarted the
keepalive; an input callback the queue had already fetched then read the freed
recorder and Hex crashed (EXC_BAD_ACCESS in objc_loadWeak,
AudioRecorderAQInputCallback, thread AQClient), instead of showing "Hex
couldn't start the microphone".

- RetiredRecorders holds a recorder that failed to start, or that a capture
  stopped, for 5 s before it is freed. Nothing reports when the queue's last
  callback ran; disposal takes about a millisecond in the simulator log.
- beginCapture stops and retires the recorder before throwing; the capture
  adapter retires it on stop (once, so a second stop is a no-op).
- startKeepalive removes its tap and resets the engine when engine.start()
  throws, so a failed start leaves nothing half-installed.

The keyboard's own capture (KeyboardLocalDictation / KeyboardWebCapture)
records through WebKit's getUserMedia and gets its callbacks on the main
thread through WKScriptMessageHandler; it has no audio-thread callback or
weak read like this, so it is unchanged.

Tests (DictationControllerTests): a microphone that fails when the keyboard
opens Hex shows the message in the app and the keyboard, leaves no job,
capture or keepalive behind, and the next Hex key records; a recorder end
arriving after teardown changes nothing; a retired AVAudioRecorder outlives its
owner for the hold and is then freed.

Verified on iOS 27.2 simulators on the Mac Studio (no microphone input):
- Keyboard (keyboardNeedsHex) > Hex key in Messages > Hex: before, 2 crashes
  in 21 runs with this stack; after, 0 crashes in 20 runs (10 cold launches,
  10 warm), Hex alive and showing "Hex couldn't start the microphone. Try
  again." each time.
- In-app Dictate, 5 times: the message each time, same process, no crash.
- An uncommitted stress test of SystemAudioManager's failing start (100 x
  beginCapture then startKeepalive): crashed the test host 2 of 2 before,
  passed 3 of 3 after.
- xcodebuild test: 391 tests, 0 failures (1 skipped).
2026-11-21 03:16:37 +00:00
..
Fixtures iOS: emoji panel with on-device suggestions (Experiments › Emoji) (#2051) 2026-11-20 15:53:24 +00:00
AutocorrectEngineTests.swift iOS: Ukrainian keyboard layout (#2128) 2026-11-21 02:30:15 +00:00
CleanupTaggerTests.swift iOS: Clean up what I say keeps names, and is on by default (#2132) 2026-11-21 03:12:53 +00:00
CustomVocabularyTests.swift ios: custom vocabulary experiment (#1547) 2026-11-08 12:15:00 -05:00
DictationControllerTests.swift iOS: keep a failed recorder alive until its audio queue stops calling back (#2133) 2026-11-21 03:16:37 +00:00
DictationLearningTests.swift ios: learn dictation and typing fixes from edits (Learn how I type) (#2022) 2026-11-20 01:04:58 +00:00
DotScopeTests.swift fix(ios): eliminate handoff frame stalls and add overlapping ballistic swipe throw (t1153) (#757) 2026-10-31 22:14:22 -07:00
EmojiSuggesterTests.swift iOS: emoji panel with on-device suggestions (Experiments › Emoji) (#2051) 2026-11-20 15:53:24 +00:00
FullKeyboardEngineTests.swift iOS: Emoji and Swipe typing are on by default, under Settings › Keyboard (#2129) 2026-11-21 02:41:15 +00:00
HexKeyGestureTests.swift iOS: the keyboard starts listening on touch-down, with its capture page ready when it opens (#2089) 2026-11-20 20:04:35 +00:00
KeyboardBridgeTests.swift iOS: Hinglish dictation, Hindi in Latin letters (Experiment, off by default) (#2119) 2026-11-21 00:29:24 +00:00
KeyboardLayoutTests.swift iOS: Emoji and Swipe typing are on by default, under Settings › Keyboard (#2129) 2026-11-21 02:41:15 +00:00
ShiftStateMachineTests.swift iOS: full keyboard experiment flag, key layout and shift model (#910) 2026-11-01 12:43:35 -08:00
SwipeDecoderTests.swift iOS: swipe typing for English and Spanish (Experiment, off by default) (#2106) 2026-11-20 22:30:53 +00:00
TranscriptCleanupTests.swift iOS: Clean up what I say keeps names, and is on by default (#2132) 2026-11-21 03:12:53 +00:00
TypingLogTests.swift iOS: Norwegian, Spanish and German full-keyboard layouts 2026-11-20 07:52:48 -05:00