Android (Native Port)
Android: genuinely native port (no Capacitor/WebView)
Section titled “Android: genuinely native port (no Capacitor/WebView)”The mobile path is native — the same winit+wgpu Rust stack plus embedded libnode, no browser shell.
- Shell:
packages/android-shell— acdylib(libdowndraft_android.so) implementingandroid.app.NativeActivityviaandroid-activity. It statically linksdowndraft-platform(so the winit loop on the app thread and the JS thread share the same event-queue statics — JSdlopens this .so, never a separate platform lib), extractsassets/bundle/→internalDataPath/bundle/viamanifest.txt(AAssetDir cannot enumerate subdirs), redirects stdio→logcat (tagdowndraft), then runsnode::Startonbundle/index.jsfrom a spawned thread. - libnode:
packages/node-mobile— an overlay recipe (pinnednode-version.txt+ sha256 +patches/series +overlay/files) applied to pristine upstream Node v26.10.0;packages/node-mobile/scripts/build-android.mjsproducesbuild/dist/android/<abi>/libnode.soforarm64-v8a/x86_64. NDK r30 required — r28’s clang 19 can’t compile V8 14.6’s consteval regexp dispatch (needs clang ≥20);deps/v8/include/atomic-ref-shim.hpolyfillsstd::atomic_reffor NDKs ≤r28 whose libc++ strips it (no-op on r30), plusg++host toolset for V8’s C++20 alias-CTAD.--v8-disable-temporal-supportis set (vendored Temporal Rust has no Android wiring).NODEJS_MOBILE_FLAVOR=litebuilds a smaller libnode (--with-intl=none --without-amaro --without-inspector --without-sqlite, ~17MB smaller binary, ~50MB lower PSS) intobuild/dist/android-lite/<abi>/— the engine degrades gracefully (sqlite→in-memory import cache, inspector→no CDP devtools, noIntl.*). - Packaging:
draft release --target=android→packages/cli/scripts/package-mobile.mjs— Bun-bundles the entry + workers as.mjsfiles underassets/bundle/(repo-rel layout,index.jsshim), stagesdd-assets/+node_modules/koffi+@koromix/koffi-android-*, writesmanifest.txt, then assembles the APK directly withaapt2/zip/zipalign/apksigner(hasCode=false— no Gradle/dex needed).packages/android-shell/gradle/is an equivalent Android-Studio skeleton. Staged.sos arellvm-stripped (--no-stripto keep symbols); optional engine cdylibs stage only when the bundle references theirdowndraft_<lib>token (--libs=/--exclude-libs=to override);--node-flavor=liteselects the lite libnode. - Lifecycle: on Android
dd_window_createonly records the request — the winit loop creates the Window onresumed()(or via EventLoopProxy wakeup). Wire events 15/16/17 = touch/suspended/resumed;NativeWindowblocks for the first RESUMED, drops+rebinds the wgpu surface across suspend/resume, and synthesizes pointer+mouse events from touch. - ABI note: engine cdylibs ship as separate
lib/<abi>/libdowndraft_*.soand are resolved by bare soname (lib-paths.tsandroid branch).libdowndraft_platform.sois intentionally not shipped standalone — it would duplicate the event-queue statics. - Env: shell sets
HOME,TMPDIR,DOWNDRAFT_DATA_DIR(= internalDataPath),DOWNDRAFT_BUNDLE_DIR(= extracted bundle root; packaged bundles resolveimport.meta.dir/assets/workers under it). - API floor: minSdk 30 (Android 11, ~87% install base) — covers the bionic surface libuv wants (
statx/faccessat2/memfd/pthread_cond_clockwait) and prunes the bad-Vulkan-driver era. Override:--min-sdk(packager),--android-api(build-native.mjs),--sdk(build-android.mjs),DD_MIN_SDK(Gradle). Target SDK is 36.