Skip to content

fix(ios): stop the speech permission prompt from crashing on Allow - #196822

Merged
obviyus merged 1 commit into
mainfrom
fix/ios-speech-permission-crash
Nov 10, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/ios-speech-permission-crash

Conversation

@obviyus

@obviyus obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

On iOS, tapping Allow on the speech-recognition permission prompt crashes the app (EXC_BREAKPOINT). This hits every new user the first time they use dictation, Talk or Voice Wake, and also when they request Speech Recognition from Settings → Device Settings → Permissions.

Root cause

Both call sites pass a closure literal to SFSpeechRecognizer.requestAuthorization from inside PermissionRequestBridge.awaitRequest's start closure, which is @MainActor. Under Swift 6 the literal inherits that main-actor isolation. TCC calls the handler on a background queue, so the runtime isolation check (swift_task_isCurrentExecutor → dispatch_assert_queue_fail) traps.

Crash frames on main:

  • dictation: closure #1 in closure #1 in static VoicePermissionSupport.requestSpeechPermission()
  • Settings: closure #1 in closure #2 in IOSDeviceSettingsPermissions.request(_:isCurrent:)

Change

Mark both handlers @Sendable, so they are nonisolated and only forward the result to the bridge's @Sendable completion, which is already thread-safe.

Evidence

Fresh iPhone 17 simulator per run (iOS 27):

Path main This PR
Chat dictation → mic Allow → speech Allow Crash No crash; mic + speech granted; dictation usable
Settings → Device Settings → Permissions → Speech Recognition → Allow Crash No crash; row shows Allowed

I also checked the other requests on the same Permissions page on main: Contacts, Photos, Notifications, Calendars, Reminders, Camera, Microphone and Location. None of them crash, so the fix is limited to the two speech handlers.

SwiftFormat and SwiftLint strict are clean. There's no unit test: the trap needs the real TCC callback queue, so the simulator run above is the proof.

Size: +4/−2 production lines.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Speech prompt on main (tapping Allow crashes) and the fix after Allow from dictation and Settings.

main: speech prompt from dictation; Allow crashes

PR: after Allow, dictation keeps running

PR: Settings shows Speech Recognition Allowed

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR marks both iOS speech-authorization callbacks @sendable to prevent inherited main-actor isolation from trapping.

Example: On a fresh iPhone 17 simulator running iOS 27, request Speech Recognition from Device Settings and tap Allow.

  • Before: The background authorization callback triggers an executor assertion and crashes the app.
  • After: The callback completes and Settings displays Speech Recognition as Allowed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal, correct repair supported by targeted simulator evidence and unchanged permission safeguards.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The author reports before-and-after runs through Chat dictation and native Settings on fresh iPhone 17 simulators running iOS 27; inspected screenshots support survival after authorization and the Allowed status, with transcription outside the demonstrated scope.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Tapping Allow for speech recognition terminates the iOS app.
Reason: This collaborator-authored repair restores the existing permission flow without changing product defaults, permission scope, or public contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a focused fix for a current iOS permission crash, with no actionable correctness or security findings.

Priority: P1
Reviewed head: 4ab6fc54256ccd9b8a7be1df8cc37905835a30df

Before merge

None.

Findings

None.

Agent review details

How this fits together

Voice startup and native Device Settings request speech authorization through PermissionRequestBridge, which starts prompts on the main actor and safely receives asynchronous permission results.

flowchart TD
  A[Chat dictation and voice] --> C[Permission request bridge]
  B[Device Settings] --> C
  C --> D[iOS speech permission prompt]
  D --> E[Sendable callback]
  E --> F[Thread safe completion]
  F --> G[Resume requesting flow]
Loading

Technical review

Best possible solution:

Merge the two callback annotations once the existing CI gates pass.

Do we have a high-confidence way to reproduce the issue?

The source exposes the actor-inheritance path, and the author reports fresh-simulator failures for both callers with matching crash frames; no target code was executed during this review.

Is this the best way to solve the issue?

The annotations are the smallest complete repair: callbacks may execute off the main actor while permission initiation and result settlement retain their existing owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0c5c4754c33d.

Provenance checked

  • Voice speech permission callback keeps the original intent (f6e51ff: The earlier iOS voice implementation forwarded speech authorization into its permission completion; subsequent refactors consolidated the helper and moved it directly into the main-actor bridge.)
  • Native Settings speech permission callback keeps the original intent (ef26537: Native Settings retained ownership of OS permission prompts while Dashboard settings acquired serialized, current-document authorization checks.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +2. Total +2 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 4 2 +2
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 2 +2

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: Granting speech authorization crashes a current iOS voice workflow on first use.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Granting speech authorization crashes a current iOS voice workflow on first use.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 10, 2026, 2:33 PM ET / 19:33 UTC.

@obviyus
obviyus merged commit c301da9 into main Nov 10, 2026
87 checks passed
@obviyus
obviyus deleted the fix/ios-speech-permission-crash branch November 10, 2026 19:49
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

RomneyDa added a commit that referenced this pull request Nov 14, 2026
…196822)

(cherry picked from commit c301da9)

Release adaptation: none. Both baseline callbacks use the identical MainActor permission bridge and Sendable completion contract. Companion audit through 7bccde6 found no later same-path changes or PR mentions; existing callers, permission tests, and native source inventory require no changes. Linux host has no Swift/Xcode; real TCC callback proof remains the merged PR simulator evidence.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 5ae04a993e3977b7123016da0ee690fad2942f88)
RomneyDa added a commit that referenced this pull request Nov 15, 2026
Port Telegram callbacks, hook session keys, private-topic approvals and
interactive widgets with complete send/edit/route security companions.
Include Feishu captioned media, iOS permission Sendable callbacks,
WebKit animation/menu retirement and pending automations props handling.
Keep Matrix malformed formatted-mention parsing linear-time.
Adapt the 11.4 equivalents to the fixed beta baseline where available.

Source PRs: #196217, #191585, #196822, #194027, #197519, #198038,
#196991, #198380, #198658, #184432. Companion scope: #191647, #192162,
#198022, #197271, #194146; #197670 is folded into #197519 equivalent.

(cherry picked from commit 928c118)
(cherry picked from commit 569ca48)
(cherry picked from commit efa744e)
(cherry picked from commit c301da9)
(cherry picked from commit 641c4d5)
(cherry picked from commit b9d3fb4)
(cherry picked from commit a213a51)
(cherry picked from commit ec46689)
(cherry picked from commit 779d22e)
(cherry picked from commit 129ccc3)
(cherry picked from commit 849c050)
(cherry picked from commit b22f35f)
(cherry picked from commit 8b414e9)
(cherry picked from commit 01ecda4)
(cherry picked from commit f978e54)
(cherry picked from commit 6e60479)
(cherry picked from commit ec7b49a)
(cherry picked from commit 1d72ad0)
(cherry picked from commit 5e2c66f)

(cherry picked from commit dfb6454)

Co-authored-by: RomneyDa <[email protected]>

(cherry picked from commit f7c581c7f8bf0e57c7d8799e928a121b24462450)

Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant