Skip to content

fix(ios): prevent VoiceOver crash on stale accessibility ranges#187

Merged
hryhoriiK97 merged 1 commit intomainfrom
fix/ios-voiceover-stale-range-crash
Mar 27, 2026
Merged

fix(ios): prevent VoiceOver crash on stale accessibility ranges#187
hryhoriiK97 merged 1 commit intomainfrom
fix/ios-voiceover-stale-range-crash

Conversation

@hryhoriiK97
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 commented Mar 27, 2026

When rendered markdown content becomes shorter before accessibility elements are rebuilt, VoiceOver can request frame information using character ranges from the previous render. These stale ranges exceed the current text length and crash in NSLayoutManager glyphRangeForCharacterRange:.

Closes #183

What/Why?

Testing

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes

When rendered markdown content becomes shorter before accessibility
elements are rebuilt, VoiceOver can request frame information using
character ranges from the previous render. These stale ranges exceed
the current text length and crash in NSLayoutManager
glyphRangeForCharacterRange:.

Fix:
- Clear _accessibilityElements and set _accessibilityNeedsRebuild
  atomically before updating attributedText so VoiceOver never sees
  stale element references during the update window.
- Clamp character ranges in frameForRange:inTextView:container: so
  out-of-bounds requests return CGRectZero instead of crashing.
- Remove redundant _accessibilityNeedsRebuild assignments that could
  race with the atomic invalidation.

Closes #183

Made-with: Cursor
@hryhoriiK97 hryhoriiK97 merged commit d34f98f into main Mar 27, 2026
5 checks passed
@hryhoriiK97 hryhoriiK97 deleted the fix/ios-voiceover-stale-range-crash branch March 28, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] VoiceOver can crash when accessibility ranges outlive the current text length

1 participant