Repository navigation
Description
A native view added as a subview of the window's content view (through WindowHandle::with_raw_handle) never shows up in the accessibility tree, so VoiceOver can't reach it. We hit this embedding a WKWebView (via wry's build_as_child) to show HTML email inside a Rune window.
What's going on
AccessKit's SubclassingAdapter replaces the content view's accessibilityChildren, accessibilityHitTest: and accessibilityFocusedUIElement with its own (vendor/accesskit_macos/src/subclass.rs, children, hit_test and focus, around lines 131-161 at 21e5342). Those only answer from the AccessKit tree, so AppKit's normal subview children are dropped.
Repro
- Any Rune window on macOS. Add a visible WKWebView as a subview of the content view and load some HTML with a link in it.
- From another process, walk the window with
AXUIElementCopyAttributeValue(..., kAXChildrenAttribute)the way VoiceOver does, or just turn VoiceOver on and VO+Right Arrow through the window. - Hit test a point inside the web view with
AXUIElementCopyElementAtPosition.
Expected: the walk reaches an AXWebArea with the page's text and links, and the hit test lands inside it.
Actual: the content view's accessibilityChildren is only AccessKitNode. The walk finds no web area, and the hit test fails with -25208.
Workaround we're using
Replacing those three methods at runtime on the AccessKitSubclassOf... class, so each keeps AccessKit's answer and adds the visible native subviews. With that, the walk reaches AXWebArea with its links, images and tables, and the hit test lands on the right cell. It works, but it depends on AccessKit's class name and adds unsafe code on our side. One gotcha we hit: WebKit fills in its tree lazily, so the first walk after the view appears comes back empty and a second one shortly after is complete.
Ask
A supported way to host a native view in the accessibility tree at an element's position. Something like an El role that names a native child view, so VoiceOver reads it in layout order instead of after everything else.
Related: #111
Activity
opencodejr commentedon Nov 25, 2026
Thanks for the detailed write-up and the workaround. The code agrees with what you found: in
vendor/accesskit_macos/src/subclass.rs, thechildren,focusandhit_testoverrides answer only from the AccessKit tree, throughAdapter::view_children,focusandhit_test. AppKit's own answer is used only when there's no adapter or the call is off the main thread. Rune'svendor/accesskit_macos.patchadds that main-thread guard and nothing else there, so the content view's native subviews never get into the tree. I also didn't find any public way in Rune today to attach a native view to an element in the accessibility tree.WindowHandle::with_raw_handleonly gives you the raw handle.I'm tracking this as a feature request: a supported way to host a native child view at an element's position, so VoiceOver reads it in layout order and hit tests and focus reach it. The point about WebKit building its tree lazily is useful, since whatever we add has to cope with a first walk that comes back empty. Related: #412 (a native web view element) and #111 (WCAG and VoiceOver).
opencodejr commentedon Nov 25, 2026
I looked at making this change but haven't opened a PR. The environment I work in can't build or run macOS code, and this fix is unsafe Objective-C runtime code in
vendor/accesskit_macos/src/subclass.rsthat would run on every Rune window's content view. I don't want to propose that without compiling it and checking it with VoiceOver.What I found while looking:
accesskit_macos::SubclassingAdapter(crates/rune/src/a11y/macos.rs). The vendored crate is rebuilt fromvendor/accesskit_macos.patchbyscripts/vendor-accesskit-macos.sh, so a fix belongs in that patch.accessibilityChildren: AccessKit's root plus the superclass's own children.accessibilityHitTest:: the superclass's answer when it lands somewhere other than the content view itself, otherwise AccessKit's.accessibilityFocusedUIElement: forwarded to the window's first responder when that responder is a native subview.crates/rune/src/system_material/macos.rsadds its own host view under the content view. It must not show up as an extra child or capture hit tests.Elrole you suggest, needs an API decision from the maintainers.Your workaround and the note that WebKit fills in its tree lazily are both good starting points for whoever picks this up.
Hona commentedon Nov 27, 2026
Fixed in #2633 (
80f235400).Design decision:
vendor/accesskit_macos/src/subclass.rs(andvendor/accesskit_macos.patch) so the content view'saccessibilityChildren,accessibilityHitTest:, andaccessibilityFocusedUIElementpreserve visible native childNSViews alongside Rune's AccessKit tree:accessibilityChildrenkeeps AccessKit's nodes and appends non-empty[super accessibilityChildren]after releasing the adapter'sRefCellborrow, so native subviews (such as aWKWebViewadded viaWindowHandle::with_raw_handle) are reachable by VoiceOver and AX tree walks (including lazily populated WebKit trees on subsequent walks).accessibilityHitTest:asks[super accessibilityHitTest:]first and returns the hit when it lands on a native subview rather than the content view or an ancestor (such asNSWindow, which AppKit returns viaNSAccessibilityUnignoredAncestorwhen no subview matches), falling through to AccessKit otherwise.accessibilityFocusedUIElementforwards towindow.firstResponderwhen it is a strict descendantNSView(with a re-entrancy guard), falling through to AccessKit otherwise.RuneMaterialHostbackdrop view (crates/rune/src/system_material/macos.rs) from AppKit accessibility (isAccessibilityElement = NO,accessibilityIsIgnored = YES, emptyaccessibilityChildren/accessibilityChildrenInNavigationOrder, andnilaccessibilityHitTest:) so system material views do not leak into VoiceOver or capture hit tests.El's layout position remains tied to a first-class native view element API (Native web view element (for inline players such as YouTube embeds) #412).Verification:
cargo check -p accesskit_macos --target aarch64-apple-darwin,cargo clippy -p accesskit_macos --target aarch64-apple-darwin -- -D warnings, cleangit apply --checkofvendor/accesskit_macos.patchagainst upstreamaccesskit_macos 0.27.2, and unit tests (cargo test -p rune --lib a11y::macos_testsandsystem_material::tests).WKWebViewlazy AX tree walks, and AppKit hit-testing were not run locally on this Windows machine. Please reopen if anything still behaves unexpectedly with VoiceOver on macOS.