Skip to content

Commit b5a4ea9

Browse files
fix(android): say why libcraft.so did not load, instead of nothing at all
The load was a bare try/catch returning false. That is correct behaviour — an app with no Zig runtime is the shim-only configuration, not an error — but it threw away the dynamic linker's explanation on the way. The first time the runtime was genuinely shipped and genuinely failed to load, that cost a whole CI cycle: the APK carried lib/x86_64/libcraft.so, the app launched, all four bridge cases passed, and the entire evidence for what went wrong was that `CraftNative` never appeared in logcat. No linker line, no exception, nothing. Both outcomes are logged now, under the same tag Zig's own output uses, so the pair reads as a sequence: "libcraft.so loaded" then "registered 59 natives" means bound; the first without the second means it loaded and failed to bind; neither means it never loaded, and the warning carries the linker's own complaint about why.
1 parent 687dd81 commit b5a4ea9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/android/templates/CraftNative.kt.template

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,24 @@ object CraftNative {
110110
*/
111111
val isAvailable: Boolean = try {
112112
System.loadLibrary("craft")
113+
// Said out loud, because the two outcomes below are otherwise
114+
// indistinguishable from outside: a library that never shipped and a
115+
// library that loaded and then failed to bind both end with the shim
116+
// answering every call. Zig logs its own registration under the same
117+
// tag, so the pair reads as a sequence.
118+
android.util.Log.i("CraftNative", "craft: libcraft.so loaded")
113119
true
114120
} catch (e: UnsatisfiedLinkError) {
121+
// The reason, not just the fact. This used to be a bare `false`, and
122+
// the first time the runtime was genuinely shipped and genuinely
123+
// failed to load, the only evidence anywhere was that nothing
124+
// happened — no linker line, no exception, nothing in logcat at all.
125+
// The message carries the dynamic linker's own complaint, which is the
126+
// one thing that says *why*.
127+
android.util.Log.w("CraftNative", "craft: libcraft.so did not load: ${e.message}")
115128
false
116129
} catch (e: SecurityException) {
130+
android.util.Log.w("CraftNative", "craft: libcraft.so was refused: ${e.message}")
117131
false
118132
}
119133

0 commit comments

Comments
 (0)