Skip to content

Crash of experiemental Android version due to Rust embedding#46

Open
kasnder wants to merge 1 commit into
mainfrom
docs/android-ndk-context-startup-panic
Open

Crash of experiemental Android version due to Rust embedding#46
kasnder wants to merge 1 commit into
mainfrom
docs/android-ndk-context-startup-panic

Conversation

@kasnder

@kasnder kasnder commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

What

Files a tracking/RFC note for a low-severity, non-deterministic Android startup crash and proposes the fix. Doc: docs/android-ndk-context-startup-panic.md. No code change — this PR is the write-up so the fix can be scheduled deliberately.

The issue

On an abrupt/stressed cold start the Android app aborts during startup:

panicked at ndk-context-0.1.1/src/lib.rs:87: (Android context not initialized)
via tao-0.34.5 .../android/ndk_glue.rs — panic in a function that cannot unwind → SIGABRT

Root cause is upstream tao 0.34.5, not our code: create() (from MainActivity.onCreate) calls ndk_context::initialize_android_context(), and an unguarded android_context() access during early lifecycle (a JNI callback / event-loop thread) can run before it → panic that can't unwind → abort. Our Rust (src-tauri/, tauri-plugin-android-blocker/) never references ndk_context.

Why it's low severity

  • UI-process only, and self-recovering (relaunch works every time observed).
  • Enforcement is unaffected — blocking runs in the Kotlin BlockerService + WorkManager, independent of the Tauri UI process.
  • Non-deterministic: ~28 launches reproduced it 0×, but a prior intense dev session left 6 tombstones. Narrow timing race.

Proposed fix

Bump Tauri 2.9.5 → 2.11.x (→ wry 0.55tao 0.35). tao 0.35 replaces the panicking android_context() with main_android_context() -> Option<..> and graceful let Some(..) else handling, plus a synchronized activity-creation handshake — removing this panic class. No first-party code change is needed for the crash itself.

Not applied in this PR because a minor Tauri bump is cross-cutting (desktop signing/notarization, iOS, Android, all enforcement/display paths) and must not ship untested. The doc includes a verification plan. Happy to take the actual bump + regression pass as a follow-up PR.

Note: the Android app currently lives on codex/android-tauri-blocker-clean; this note is filed against main so the version facts (tao 0.34.5 also underlies desktop wry) and the scheduling are visible there.

🤖 Generated with Claude Code

Document a low-severity, non-deterministic Android startup crash: tao 0.34.5's
ndk_context::android_context() can be accessed before create() initializes it
on an abrupt cold start, aborting the UI process (SIGABRT). Root cause is
purely upstream tao (our Rust never touches ndk_context); enforcement is
Kotlin so blocking is unaffected and the crash self-recovers on relaunch.

Proposed fix: bump Tauri toward 2.11.x, which brings tao 0.35 / wry 0.55 where
the panic is replaced by main_android_context() -> Option<..> with graceful
handling. Not applied here because the minor Tauri bump needs a full
cross-platform regression pass; this note tracks it with a verification plan.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kasnder kasnder changed the title docs: Android tao ndk-context startup panic — issue + proposed fix Crash of experiemental Android version Jul 7, 2026
@kasnder kasnder changed the title Crash of experiemental Android version Crash of experiemental Android version due to Rust embedding Jul 7, 2026
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