ReviewOS

craft-native/craft

perf(android): the shipped libcraft.so carries debug info, ~5.5 MB per ABI

#204
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Now that the generator installs the Zig runtime into app/src/main/jniLibs/<abi>/libcraft.so, every generated app's APK carries it — and at -Doptimize=ReleaseSafe each library is built with debug info:

5,761,056  zig-out/android/arm64-v8a/libcraft.so
5,565,632  zig-out/android/x86_64/libcraft.so

file reports "with debug_info, not stripped" for both, so a universal APK ships roughly 11 MB of native library, most of it DWARF.

AGP would normally strip native libraries at packaging time, but its stripDebugSymbols task shells out to the NDK's strip, and the generated project configures no NDK — the JNI library deliberately needs none to build (android_dispatch.zig:77-89 explains why it links no libc). So the strip step has nothing to run and the symbols ship.

Worth measuring before choosing:

  1. What a stripped library actually costs — -Dstrip on the two JNI artifacts in build.zig:2428-2467, or .strip = true on those modules for release builds only.
  2. Whether keeping debug info is worth it. Nothing currently symbolicates a native crash from a generated app; there is no upload step and no symbol store, so today the DWARF is paid for and unused.
  3. Whether ABI splits belong here — most apps do not need both architectures in one artifact, and splits { abi { … } } is a one-block change to build.gradle.kts.app.template.

Not urgent: correctness came first and the runtime now genuinely loads and binds. But it is a cost every generated app pays from the commit that shipped it, so it should not go unmeasured for long.

Found while implementing #200.

Sign in to comment on this issue.