Skip to content

Android WebView backend + Nota example - #2

Merged
ysdragon merged 9 commits into
mainfrom
android
Sep 5, 2026
Merged

ysdragon merged 9 commits into
mainfrom
android

Conversation

@ysdragon

@ysdragon ysdragon commented Sep 5, 2026

Copy link
Copy Markdown
Owner

What I did

I ported the same webview_* Ring C-API to Android, backed by
android.webkit.WebView through JNI — one main.ring runs on desktop and
Android via ring2apk. Package
io.github.ysdragon.webview.

  • Backend: src/c_src/ring_webview_android.c +
    src/android/…/MainActivity.java + proguard-webview.pro. Desktop and
    Android builds are mutually exclusive in CMake.
  • Threading: the UI thread owns the WebView and only enqueues; a worker
    owns the Ring VM behind a bounded (4096) condvar-gated queue. JNI
    enqueues raw events, g_on* callbacks are worker-only, lifecycle flags
    are C11 atomics. Stale wreturns drop instead of crashing.
  • Lifecycle: rotation re-attaches without destroy; a killed renderer
    rebuilds the view and reloads the last HTML/URL — poison pages stop after
    3 crashes in 10s. Single instance per process.
  • Example: Nota notes app under examples/android/ — add/edit/pin/
    delete/search, file persistence, glassmorphism UI, bridge driven by native
    onDomReady (no polling).
  • Packaging/docs: ring2apk 1.1.0 dependency, example + backend in
    package.ring, version bumped to 1.6.0 with a 1.5.2 versions entry,
    docs/ANDROID.md starter guide, Android sections + device screenshot in
    the READMEs.

Nothing here breaks the API — it's additive over dev. The 1.6.0 number
comes from the yyjson bridge break already in dev, not from this branch.

Tested (device, arm64)

  • examples/android/ring/fulltest.ring — 20/0, zero JS console errors.
  • Notes survive close/reopen (files/notes.db); rotation keeps state;
    idle-kill restores content.
  • NDK -Wall -Werror clean, javac clean, Java mirrors in sync.

Same webview_* Ring C-API as desktop, backed by android.webkit.WebView
over JNI. Package io.github.ysdragon.webview.

UI thread owns the WebView and only enqueues; worker thread owns the
Ring VM and runs the job queue. g_on* names are worker-only; JNI
enqueues raw events. Flags are C11 atomics; queue bounded at 4096.
Rotation re-attaches and re-pushes shim+scripts; renderer crash
rebuilds the view and reloads. Single instance per process.
Adds CMake target for ring_webview_android when building for Android,
linking against android, log, and yyjson libraries.
Notes app with glassmorphism mobile UI: add/edit/pin/delete/search,
file-backed persistence, bridge driven by native onDomReady.
Includes ring2apk config, Java/C sources, README, and screenshot.
Update README to include Android in cross-platform features list,
add collapsible Android setup section, and document Nota example app.
@ysdragon
ysdragon merged commit fc58e3f into main Sep 5, 2026
0 of 10 checks passed
ysdragon added a commit that referenced this pull request Sep 5, 2026
Android WebView backend + Nota example
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.

1 participant