Skip to content

Android: TalkBack #2697

Done
Done

Description

@pascalandr

Part of the Android series (#2484), on the host of #2689. Needs touch (#2649) for explore by touch.

Gap on dev (2f15e4a90)

  • The accessibility feature has adapters for Windows, macOS and Linux only (crates/rune/src/a11y/mod.rs:41-45), so on Android a screen reader sees one unnamed view.

Slice

  • RuneView returns an AccessibilityNodeProvider; its three calls and, with touch exploration on, the hover events go over JNI to accesskit_android's low-level Adapter, on the UI thread where the runtime lives. The existing AccessibilityLink queues activation and actions for the next frame.
  • The root node is the view itself, focusable for keys: TalkBack took it for one control and skipped every text. Its node is made passive, and each text leaf is screen-reader focusable (API 28+).
  • Scroll pacing (a pure step, host-tested): at rest each frame's changes are sent; while a viewport scrolls, at most one sync per 100 ms, then at once on the frame it rests.

Checked (on the fork's host)

  • Host: 5 pacing tests (rest, hold, a one-second fling at 120 Hz syncs about ten times, the resting frame, the wake).
  • API 35 emulator, TalkBack 15.0, with real touchscreen events so they pass through TalkBack: explore by touch focuses the button or the label under the finger; swipe right walks label, button, switch, checkbox, segments in order; double-tap opens a dialog and focus moves into it. uiautomator dump lists 149 nodes for the kit gallery with roles, names and checked states.
  • Xiaomi 14 (Android 16, 120 Hz), kit gallery scrolled for two minutes, three runs each way: 97.6 % of frames within one period with TalkBack off, 98.3 % on; TalkBack costs about a third more CPU (0.45 to 0.60 cores).
  • Not checked: what TalkBack says (no audio capture), typing in a field with TalkBack, Switch Access, Voice Access.

Cost: accesskit_android 0.9.1 depends on jni 0.21 while the lock has 0.22, so a second jni enters Cargo.lock.

Reference: NeuralNomadsAI/rune@android/s5-services...android/s4-a11y (the fork's host predates #2689; a11y/android/throttle.rs and its tests are host-independent).

Questions

  1. Is the second jni acceptable until accesskit_android moves to 0.22, or do you prefer a hand-written node mapping?
  2. A scroll viewport's single content child is what TalkBack calls a list item, so its plain texts are read as one unless marked focusable. We marked every text leaf; would you rather decide it per role in the tree?

Activity

  1. opencodejr commented on Nov 28, 2026

    @opencodejr
    Contributor

    the native host from #2689 is on dev (touch in #2649 is still waiting on design), and crates/rune/src/a11y/mod.rs:41-46 / crates/rune/Cargo.toml:120 confirm android has no accessibility adapter yet. this raises two design calls before building:

    1. accesskit_android (with jni 0.21 alongside jni 0.22) vs a hand-written mapping: PLAN.md commits to accesskit rather than custom per-os bridges, and Cargo.lock already carries a second objc2 (0.5.3 beside 0.6) for accesskit_macos. jni 0.22 only enters via winit -> android-activity (platform/android/host.rs uses raw jni-sys), so a temporary android-only jni 0.21 follows existing precedent and avoids maintaining a separate AccessibilityNodeInfo / action / text-range bridge. keeping the passive-root and focusability adjustments on the RuneView / adapter side also avoids adding another [patch.crates-io] vendor entry.
    2. screen-reader focusability granularity (every text leaf vs per role): a11y_repeats_control (crates/rune/src/a11y/tree.rs:574) already collapses text inside leaf_control roles (Button, Switch, CheckBox, RadioButton, Tab, ListBoxOption, Link, MenuItem), but not inside ListItem, Row, Article, Heading, Paragraph, or labelled Group. marking every Label leaf screenReaderFocusable stops talkback from merging a scroll viewport's content into one announcement, at the cost of splitting multi-text rows/cards into separate swipes; a role-based rule (closer to chromium's BrowserAccessibilityAndroid, grouping plain text inside ListItem/Article/Heading/Paragraph while keeping standalone text leaves focusable) keeps composite items as one stop.

    the pure scroll-pacing step (throttled while scrolling, immediate on rest) fits cleanly alongside RuntimeCore::scrolling (runtime/layout_read.rs:661) and web_a11y_scroll_active (runtime/web/a11y.rs:1083).

    questions for maintainers:

    • should android accessibility use accesskit_android (accepting a duplicate android-only jni 0.21 in Cargo.lock until upstream moves to 0.22), or a hand-written node mapping?
    • for talkback focusability inside scroll views, should we mark every text leaf screenReaderFocusable (api 28+), or decide it per role so ListItem/Article/Heading/Paragraph keep their plain text children grouped as one swipe stop?
  2. pascalandr commented on Nov 28, 2026

    @pascalandr
    Author
    1. accesskit_android with the second jni: the fork's choice, no trouble met with it.
    2. Per role is the better rule. The fork marked every text leaf because the content of a scroll viewport was otherwise read as one item; a rule that keeps ListItem, Article, Heading and Paragraph as one stop and standalone text focusable fixes the same thing without splitting rows.
  3. Hona commented on Nov 28, 2026

    @Hona
    Member

    Implemented in #2713 (merged on dev as adb52ae84).

    Design decisions

    • Adapter: wired accesskit_android 0.9.1 (accepting the Android-only jni 0.21 dependency alongside jni 0.22 until upstream updates) behind the accessibility feature, bridging RuneView's AccessibilityNodeProvider (createAccessibilityNodeInfo, findFocus, performAction) and touch-exploration hover events (dispatchHoverEvent) on the UI thread via AccessibilityLink, with QueuedEvents::raise strictly after releasing HOST borrows.
    • Passive host root: HOST_VIEW_ID (-1) and onInitializeAccessibilityNodeInfo strip focusable/clickable/accessibility-focus actions and move any window title into API 28+ paneTitle, and findFocus(FOCUS_INPUT) returns null when keyboard focus rests on the root Window.
    • Per-role screenReaderFocusable & isHeading grouping (API 28+): ListItem, Article, Heading, and Paragraph keep their plain text grouped as one swipe stop (with isHeading = true on Heading), while standalone Label leaves (and standalone labelled Image leaves) outside grouping roles or leaf controls get screenReaderFocusable = true so TalkBack walks them individually inside scroll views.
    • Scroll pacing: explicit Rest / Cooldown / Holding state machine (a11y/android/throttle.rs) syncs immediately at rest, caps syncs to once per 100 ms while RuntimeCore::a11y_scroll_active() is true, flushes immediately on the resting frame, and schedules a fenced Attempt wake when frames stop.

    What was verified vs not run on hardware

    • Verified locally: 10 host unit tests in a11y::android (5 scroll-pacing tests including a 1 s 120 Hz fling + 5 per-role focusability and Runtime::accessibility_tree() tests), all a11y:: (150 tests) and platform::android:: (40 tests) host suites, and cargo check -p rune --no-default-features.
    • Verified in CI: android (aarch64-linux-android, x86_64-linux-android with rune/accessibility, plus kotlinc/d8 and android-hello APK build), check, and size all passed.
    • Not run on real hardware: not tested on a physical Android device or Android emulator running TalkBack (explore by touch, spoken announcements, text-field editing with TalkBack, Switch Access, or Voice Access). Please reopen if anything behaves unexpectedly on device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions