astronomy: fall back to Kotlin when the Rust ephemeris is not loaded
- Commit
66e0ceed8b9116c82b1ddc9fc8d68451e0410fcb- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 14:24 UTC (29 days ago)
- Parents
e9eec08
CoordinateTransforms.batchRaDecToAltAz called the JNI batch transform unconditionally. Where the Rust library does not load - any ABI the APK does not ship, such as the x86_64 emulator (rustNativeLib ships arm64 by default) - the first visible-sky computation died with UnsatisfiedLinkError and took the process down, as the on-device LaunchNoCrashTest shows. AstronomyNative documents that callers with a Kotlin equivalent must check available and fall back, and projectAll already does; this caller now does the same, transforming one by one with raDecToAltAz. (cherry picked from commit b98c62cdb2f515252693f99308c3eb10ac175768)
Diff
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.ktindex d78be57ddc..67e2a5cbc8 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt@@ -85,6 +85,12 @@ object CoordinateTransforms { // transform in Rust, rebuild the List<AltAz>. fun batchRaDecToAltAz(radecs: List<RaDec>, lstRad: Double, latRad: Double): List<AltAz> { if (radecs.isEmpty()) return emptyList()+ // Same guard projectAll has: where the Rust library did not load+ // (an ABI the APK does not ship, e.g. x86_64), transform in Kotlin+ // rather than dying with UnsatisfiedLinkError.+ if (!com.vayunmathur.astronomy.domain.AstronomyNative.available) {+ return radecs.map { raDecToAltAz(it, lstRad, latRad) }+ } val input = DoubleArray(radecs.size * 2) for (i in radecs.indices) { input[2 * i] = radecs[i].raRad