-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwiftUI Views with ScrollViews for iOS 14 don't record Voice Over Descriptions #33
Comments
Thanks for the report @fbernutz! I'll run through it in the debugger and see if I can figure out what's going on. |
Hmm, this is an interesting edge case. It seems like SwiftUI isn't quite implementing the UIAccessibility API the way I understand it's meant to work. The UIHostingView now acts as an accessibility container with the scroll view as its only element. Because the scroll view is not an element (as expected), this results in there being no elements shown when we parse through the hierarchy.
VoiceOver seems to recover from this though, and keeps searching for other elements. I need to keep digging to figure out how it determines whether to accept that an accessibility container is empty vs. continuing to search for other elements. |
Maybe this behavior is a bug in iOS 14.0? I haven't tested it with one of the iOS 14 betas. Will do later. |
the issue exists in iOS 14.1 (Xcode 12.1 GM) as well... BUT in iOS 14.2 beta (Xcode 12.2 beta 3) it seems to be fixed, the snapshot looks great there. |
Did some testing on iOS 13 and there's definitely some existing behavior around accessibility containers that we aren't getting right. It looks like nesting accessibility containers will include all of the elements in the hierarchy, but I still need to do some experimenting to figure out how it deals with ordering the elements and some of the edge cases. |
Working on debugging the nested container handling in #46 |
So, from what I can tell, we're actually handling nested accessibility containers correctly, with the exception of some edge cases around ordering that shouldn't affect this case. I ran the scroll view test you added in #34 on iOS 14.1 and stepped through the parser, and got this:
The hosting view acts as an accessibility container, vending only the scroll view. The scroll view isn't an element itself or an accessibility container, so we look at its subviews. The first subview is the Testing this on 14.2, the
It definitely seems like this was a SwiftUI bug in iOS 14.{0,1} that's now fixed in iOS 14.2. I'm not sure how exactly VoiceOver was still able to find the elements (presumably it must communicate with SwiftUI in a different way), but I don't see anything through the UIAccessibility API that would give us access to them. 😕 |
Thanks for your analysis. As iOS 14.2 is already officially released, I'll change my snapshot references to 14.2 soon, so there's no need for a workaround for the two other iOS versions I think. |
I just added snapshots for iOS 14.2 (see #52) if you want to add some regression tests for this. Happy to close out this issue now, or anything else you think needs to be addressed? |
Awesome, just saw that! Thanks for all the support and feel free to close this issue. |
Something seems to have changed from iOS 13 to iOS 14 with SwiftUI ScrollViews.
When snapshotting a SwiftUI View with a ScrollView (only iOS 14), no Accessibility Nodes can be found. I tried to debug this and found differences in the objects when the SwiftUI View had a ScrollView and when it had no ScrollView.
iOS 13: Elements inside a ScrollView are of type NSObject
Screenshot
iOS 14: Elements inside a ScrollView are of type UIView (SwiftUI_UIShapeHitTestingView)
Screenshot
This results in no accessibility nodes for the iOS 14 snapshot.
I've tried to fix this but honestly I have no idea how 🙈
I've also added a draft PR #34 with two new snapshot tests where you can see the resulting snapshot for these scenarios. If there are any more information needed to look into this, I'm happy to help.
The text was updated successfully, but these errors were encountered: