From 37f90ed7f4fc6fcc6c281e89910a4146db9795be Mon Sep 17 00:00:00 2001 From: Angelos Veglektsis Date: Fri, 6 Nov 2026 14:52:35 +0200 Subject: [PATCH 1/2] gl-sdk: unwind on panic in the Android and iOS libraries The workspace's release profile sets panic = "abort", so on iOS a Rust panic in the SDK aborts the app instead of reaching Kotlin or Swift as an exception. The Android, iOS and iOS simulator tasks override it with CARGO_PROFILE_RELEASE_PANIC=unwind. The Android libraries are debug builds and already unwind; the override keeps them unwinding once they build in release. --- build/.tasks.yml | 6 ++++++ libs/gl-sdk/CHANGELOG.md | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/build/.tasks.yml b/build/.tasks.yml index 957941323..1cb3c8130 100644 --- a/build/.tasks.yml +++ b/build/.tasks.yml @@ -52,6 +52,10 @@ tasks: vars: ABI: '{{index .MATCH 0}}' ARCH: '{{index .MATCH 1}}' + # The workspace's release profile aborts on panic. The SDK libraries unwind instead, so UniFFI + # hands a Rust panic to Kotlin or Swift as an exception rather than aborting the app. + env: &sdk_env + CARGO_PROFILE_RELEASE_PANIC: unwind cmds: - cargo ndk -t {{.ARCH}}-linux-{{.ABI}} -o target/release/android/jniLibs build -p gl-sdk @@ -70,11 +74,13 @@ tasks: ios-apple-*: vars: ARCH: '{{ index .MATCH 0 }}' + env: *sdk_env cmds: - IPHONEOS_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target {{.ARCH}}-apple-ios -p gl-sdk ios-sim-apple-*: vars: ARCH: '{{ index .MATCH 0 }}' + env: *sdk_env cmds: - IPHONEOS_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target {{.ARCH}}-apple-ios-sim -p gl-sdk diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index 55d68b47a..4afa89d60 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Changed + +- iOS (Kotlin and Swift): a Rust panic in the SDK reaches the app as an exception instead of aborting it, as it already does on Android. The Android and iOS libraries unwind on panic, unlike the workspace's release profile. + ## [0.5.0] - 2026-10-12 ### Added From c3d94192da06aa6a59934b0cd1eaaa63cc58e3dd Mon Sep 17 00:00:00 2001 From: Angelos Veglektsis Date: Fri, 6 Nov 2026 14:54:43 +0200 Subject: [PATCH 2/2] gl-sdk: build the Android libraries in release mode The Android tasks ran `cargo ndk ... build` without `--release`, so the Kotlin package shipped dev-profile libraries: unoptimized, with debug assertions, and almost three times the size of a release build (arm64-v8a libglsdk.so: 29.9 MB, 11.0 MB in release). The iOS tasks already build in release. The Kotlin bindings are generated from the release arm64 library, which yields the same Kotlin as the debug one. --- build/.tasks.yml | 4 ++-- libs/gl-sdk/CHANGELOG.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/.tasks.yml b/build/.tasks.yml index 1cb3c8130..57efc6464 100644 --- a/build/.tasks.yml +++ b/build/.tasks.yml @@ -26,7 +26,7 @@ tasks: GOBLEY_ROOT: target/gobley cmds: - cargo install --locked --git {{.GOBLEY_GIT}} --rev {{.GOBLEY_REV}} --root {{.GOBLEY_ROOT}} --bin gobley-uniffi-bindgen gobley-uniffi-bindgen - - "{{.GOBLEY_ROOT}}/bin/gobley-uniffi-bindgen --config ./libs/gl-sdk/uniffi.kotlin-multiplatform.toml --library ./target/aarch64-linux-android/debug/libglsdk.a --out-dir target/release/kotlin-multiplatform" + - "{{.GOBLEY_ROOT}}/bin/gobley-uniffi-bindgen --config ./libs/gl-sdk/uniffi.kotlin-multiplatform.toml --library ./target/aarch64-linux-android/release/libglsdk.a --out-dir target/release/kotlin-multiplatform" - cp -a ./target/release/kotlin-multiplatform/* libs/gl-sdk-android/lib/src/ - mkdir -p libs/gl-sdk-android/lib/src/lib/ios-arm64 - mkdir -p libs/gl-sdk-android/lib/src/lib/ios-simulator-arm64 @@ -57,7 +57,7 @@ tasks: env: &sdk_env CARGO_PROFILE_RELEASE_PANIC: unwind cmds: - - cargo ndk -t {{.ARCH}}-linux-{{.ABI}} -o target/release/android/jniLibs build -p gl-sdk + - cargo ndk -t {{.ARCH}}-linux-{{.ABI}} -o target/release/android/jniLibs build --release -p gl-sdk ios: deps: diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index 4afa89d60..eb98cc3bb 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - iOS (Kotlin and Swift): a Rust panic in the SDK reaches the app as an exception instead of aborting it, as it already does on Android. The Android and iOS libraries unwind on panic, unlike the workspace's release profile. +### Fixed + +- Android: the native libraries are built in release mode. They were unoptimized debug builds with debug assertions, and the `arm64-v8a` `libglsdk.so` shrinks from 29.9 MB to 11.0 MB. + ## [0.5.0] - 2026-10-12 ### Added