Repository navigation
Commit 535b5fd
Remove UIView scoping from the index-API fallback
The `!(self is UIView)` guard in `resolvedAccessibilityElements()` was added
(commit 6c5ef33) to fix a parser hang, attributed to "UIKit synthesizes
accessibilityElementCount() from the subview tree." Probing UIKit shows that
rationale is false: plain, child-bearing, and `shouldGroupAccessibilityChildren`
views all return `NSNotFound` (== `NSIntegerMax`) from `accessibilityElementCount()`,
not a synthesized count. The hang was caused by the old `count > 0` check letting
`NSNotFound` through, looping ~`NSIntegerMax` times — the actual fix for which is
the `count != NSNotFound` sentinel guard added later (commit b991cfc).
With the sentinel guard in place the `UIView` exclusion is no longer needed to
prevent the hang, and it actively defeats the purpose of the fallback: a `UIView`
that exposes its children only through the `UIAccessibilityContainer` index APIs
(nil `accessibilityElements`) is exactly what the fallback should capture, and is
exactly what VoiceOver consumes. Removing the guard lets such views be resolved
correctly while leaving every standard UIKit view untouched.
Verified that no view is affected in practice: probing 18 UIKit view types, none
sit in the "nil accessibilityElements + finite positive count" bucket — they
either populate `accessibilityElements` (e.g. UISegmentedControl, UIPickerView,
UINavigationBar) or return `NSNotFound`/`0`. The only index-API implementations in
this repo are the two test helpers, so guard removal changes no existing output.
- Remove the `!(self is UIView)` guard and rewrite the doc comment to describe the
single, honest rule (accessibilityElements, else index APIs, else nil).
- Invert `testViewContainerIgnoresIndexAPIsInFavorOfSubviews` ->
`testViewContainerResolvesElementsViaIndexAPIs`: a view that vends only via the
index APIs is now resolved through the fallback, with index elements taking
precedence over subview traversal (matching VoiceOver).
Snapshot tests are gated to recorded device configs (iOS 17.5 / 18.5 / 26.2) and
must be validated in CI; local iOS 26.5 runs are not collected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent f988545 commit 535b5fd
2 files changed
Lines changed: 24 additions & 34 deletions
File tree
- Example/UnitTests
- Sources/AccessibilitySnapshot/Parser/Swift/Classes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1048 | 1048 | | |
1049 | 1049 | | |
1050 | 1050 | | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1061 | 1060 | | |
1062 | 1061 | | |
| 1062 | + | |
| 1063 | + | |
1063 | 1064 | | |
1064 | 1065 | | |
1065 | 1066 | | |
| |||
1073 | 1074 | | |
1074 | 1075 | | |
1075 | 1076 | | |
1076 | | - | |
1077 | | - | |
| 1077 | + | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
1083 | | - | |
1084 | | - | |
| 1083 | + | |
1085 | 1084 | | |
1086 | 1085 | | |
1087 | 1086 | | |
| |||
1171 | 1170 | | |
1172 | 1171 | | |
1173 | 1172 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
1180 | 1176 | | |
1181 | 1177 | | |
1182 | 1178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
900 | 898 | | |
901 | 899 | | |
902 | 900 | | |
903 | 901 | | |
904 | 902 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | 903 | | |
910 | 904 | | |
911 | 905 | | |
| |||
0 commit comments