Skip to content

feat(android): add S1 native host (RuneView, LayerHost, insets, back) - #2689

Merged
Hona merged 1 commit into
devfrom
feat/android-s1-host
Nov 28, 2026
Merged

Hona merged 1 commit into
devfrom
feat/android-s1-host

Conversation

@Hona

@Hona Hona commented Nov 28, 2026

Copy link
Copy Markdown
Member

Implements Android slice S1 (native host: RuneView, lifecycle, insets, Back) cleanly on top of S0 (#2647).

Design decisions

  • Separate keyboard inset (Cx::keyboard_inset() / Runtime::set_keyboard_inset()): Soft-keyboard overlap stays out of Cx::safe_area() so hardware El::on_edge_drag bands do not expand by the keyboard height. set_keyboard_inset invalidates memos and automatically scrolls focused text fields into the visible band above the keyboard without resizing the layout viewport (adjustNothing).
  • Kotlin package & layout: dev.rune (RuneActivity and RuneView) in crates/rune/android/src/main/java/dev/rune/, matching existing dev.rune.* IDs and using framework Android APIs (no AndroidX requirement).
  • Keep winit linked, bypass at runtime: App::try_run routes to platform::android::run on Android without touching ~235 files naming winit types or vendor/winit. rune::android_main! exports JNI_OnLoad and binds RuneView methods via RegisterNatives.
  • Detachable LayerHost + Android GLES limits: rune::embed::LayerHost compiles on Android, accepts an ANativeWindow * (from_native_window / attach_native_window), and detaches synchronously (detach_surface) while keeping the Runtime<S>, app state, and GPU device alive across surface loss. Gpu::required_device_limits falls back to downlevel_defaults() for adapters limited to 16 KiB uniform buffer bindings (Android GLES), and wgpu/gles is enabled alongside Vulkan on Android.

What shipped

  • crates/rune/src/platform/android/: pure lifecycle state machine (machine.rs + 8 host tests in machine_tests.rs), JNI host (host.rs), and stdout/stderr/panic logcat forwarding (logcat.rs).
  • crates/rune/src/platform/embed.rs: Android ANativeWindow support and detach_surface / attach_native_window.
  • crates/rune/src/render/device.rs: required_device_limits downlevel fallback for 16 KiB UBO adapters (+ unit test in device_tests.rs).
  • Cx::keyboard_inset() and Runtime::set_keyboard_inset() (+ edge-drag isolation and caret-reveal tests).
  • crates/rune/android/src/main/java/dev/rune/{RuneActivity,RuneView}.kt, examples/android-hello, scripts/android-run.sh, ANDROID.md, and an apk CI job in .github/workflows/android.yml.

Verification

  • Verified locally on Windows: cargo check -p rune -p android-hello, cargo check --target wasm32-unknown-unknown -p rune, platform::android::machine_tests (8 tests covering surface loss/recreation, 20 Home/return trips, rotation, keyboard inset without resize, dark mode, Back, Choreographer deduplication), required_device_limits, keyboard_inset (edge-drag + caret reveal), and android-hello unit tests.
  • Verified on GitHub Actions CI: android (aarch64-linux-android, x86_64-linux-android, and android-hello APK build), check, and size.
  • Not run locally: Android emulator or physical Android device runtime.

Fixes #2648

@Hona
Hona force-pushed the feat/android-s1-host branch 2 times, most recently from c043c13 to 99a0a01 Compare November 28, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android (S1): native host (RuneView, lifecycle, insets, back)

1 participant