Skip to content

Android (M7): a native host on a fork, and three questions #2484

Done

Description

@pascalandr

CodeNomad needs native Android, so we built a host in slices on a fork, one branch on top of the other: https://github.com/NeuralNomadsAI/rune/branches/all?query=android (android/s0-build to android/s8-keyboard-type, on dev 9acb5aa6f).

A Kotlin RuneView (SurfaceView paced by Choreographer) drives LayerHost over JNI, without winit: lifecycle and insets, touch, InputConnection text input, TalkBack through accesskit_android, the system's selection handles and toolbar, clipboard, system fonts, haptics. Each slice has host tests that fail before its change; the fork's CI cross-builds both Android targets and the APK. Checked on an API 35 emulator and a Xiaomi 14 (Android 16), where it holds 120 Hz with and without TalkBack.

I will ship one issue per slice with its gap and its test.

Three decisions on your side that would help:

  1. File pickers. Android's picker returns content:// URIs where Tx::open_file gives paths. Copy the picked document into the app's cache and return that path, or an API that hands a reader?
  2. El::keyboard_type(KeyboardType) (Text, Email, Url, Number, Decimal, Phone), a public API we added so a touch keyboard shows the right keys. Would you take it, and under what name? The web host's inputmode and Wayland's ContentPurpose could read it too.
  3. Focus on a tap. On Android a finger now moves focus and selection when it lifts as a tap, not when it lands, so a scroll keeps the field's focus and the keyboard up. Should touch on the web and iOS follow?

Activity

  1. opencodejr commented on Nov 26, 2026

    @opencodejr
    Contributor

    all three are design decisions that affect shared apis or cross-platform behaviour, so they need a maintainer call before slices land:

    1. file pickers (crates/rune/src/file_dialog.rs): Tx::open_file / save_file / open_folder return PathBuf and currently error on web and mobile. copying a content:// document into app cache lets existing PathBuf callers work for read-only picks, but leaves cache cleanup, large files, save_file, and open_folder awkward. a picked-file handle/reader api (like rfd::FileHandle, with name/read/write and optional path()) would fit both android content:// uris and web <input type="file">.
    2. keyboard / input mode hint (crates/rune/src/el/input.rs): bridge.js currently hardcodes inputMode = 'text' and wayland's layer_shell/text_input.rs hardcodes ContentPurpose::Normal; Web: text input semantics (email/url/search/autofill), non-PNG image paste, and visualViewport menu/caret bounds #2466 also asks for web input semantics (email, url, search, numeric, tel, plus autofill hints). following html inputmode (El::input_mode(InputMode) with Text, Email, Url, Numeric, Decimal, Tel, Search, None) lines up directly with web and still maps cleanly to android InputType, ios UIKeyboardType, and wayland ContentPurpose — or El::keyboard_type(KeyboardType) if mobile naming is preferred.
    3. focus and selection on tap-up (crates/rune/src/runtime/input/touch.rs, pointer.rs): touch_down_inner currently calls press_down on TouchPhase::Started, queueing Action::Focus / Action::Blur and press_selection before TOUCH_SLOP distinguishes a tap from a pan. web (platform/web/input.rs) already defers dom focus sync until TouchPhase::Ended, so moving touch focus/blur/selection to tap-up in shared touch.rs would keep scrolling from dismissing the keyboard across android, web, and ios alike (matching chrome, android, and uikit).

    questions for maintainers:

  2. Hona commented on Nov 27, 2026

    @Hona
    Member

    Thanks for laying out all three questions clearly — here are the design decisions for the upcoming Android slices:

    1. File pickers (content:// URIs vs PathBuf)

    Decision: Add a platform-neutral handle/reader API alongside the existing PathBuf methods — do not copy content:// documents into app cache behind Tx::open_file.

    • Copying into app cache leaves cache cleanup, eviction, and large-file copy latency awkward, and cannot cleanly handle save_file (ACTION_CREATE_DOCUMENT, which writes back through the URI's output stream) or open_folder (ACTION_OPEN_DOCUMENT_TREE).
    • Keep existing desktop Tx::open_file / open_files / save_file / open_folder (PathBuf) unchanged for backward compatibility, and introduce an additive handle API modelled on rfd::FileHandle / web File System Access handles (metadata such as name(), optional path() -> Option<&Path> returning Some on desktop and None on Android content:// and web, plus async/streaming read and write). That covers Android SAF, web <input type="file">, and iOS security-scoped URLs with one cross-platform shape.
    • Until that slice lands, Tx::open_file on Android should keep returning an unsupported error rather than staging cache copies.

    2. Soft-keyboard hint (El::keyboard_type vs El::input_mode)

    Decision: Yes, we want this as an additive El builder, named after HTML's inputmode: El::input_mode(InputMode) (default InputMode::Text).

    • Rune's existing text/a11y builders follow HTML/ARIA naming (El::live_region, El::has_popup, El::orientation, El::auto_complete, El::spellcheck, El::read_only, El::single_line).
    • Using the HTML inputmode variants (Text, None, Tel, Url, Email, Numeric, Decimal, Search) covers all six of your variants plus Search and None, pairs directly with Web: text input semantics (email/url/search/autofill), non-PNG image paste, and visualViewport menu/caret bounds #2466 on web (where autofill/credential hints remain separate from keyboard layout), and maps cleanly to Android InputType/EditorInfo, iOS UIKeyboardType, and Wayland zwp_text_input_v3::ContentPurpose.

    3. Touch focus and selection on tap-up (shared across web, iOS, and Android)

    Decision: Yes — deferring touch focus, blur, and text-field caret/selection to tap-up is now the shared default across all touch hosts, matching Chrome, Android, and UIKit.

    • Shipped in fix(touch): defer focus, blur, and selection changes to tap-up #2558 (c1860598b): Shared touch handling (runtime/input/touch_machine.rs, touch.rs, pointer.rs, selection/click.rs, plus web_touch_end_activate in input/host_events.rs) now defers focus, blur, and text-field caret/selection from TouchPhase::Started to tap-up (TouchPhase::Ended within TOUCH_SLOP). Scrolling, pinching, edge swipes, long presses, and cancelled touches leave the focused field, soft keyboard, and existing text selection untouched.
    • Tested locally: Focused headless tests (cargo test -p rune --lib -- runtime::input::touch input::host_events runtime::input::focus_key runtime::input::field_menu runtime::tests::press_pointer: 83 passed; cargo test -p rune --test integration -- link_drag: 6 passed) and cargo check -p rune --target wasm32-unknown-unknown.
    • Not tested on hardware: Not yet verified on physical Android, iOS, or mobile browser devices.

    Closing this design Q&A now that all three questions are decided and #3 is merged on dev. Feel free to open one issue per Android slice against these decisions, or reopen if anything in #2558 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