Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(android): libconcat_android.so is linked for 16 KB pages, and the phone build fails when any library is not

Jareerc41865ec7b2d
diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml
index f01f0031..2c169c15 100644
--- a/.github/workflows/mobile.yml
+++ b/.github/workflows/mobile.yml
@@ -245,6 +245,12 @@ jobs:
rm -f "$keystore"
"$tools/apksigner" verify --print-certs "$apk"
+ # A phone with 16 KB pages loads none of a library aligned to less,
+ # and the build would not say so.
+ - name: Every library is aligned for 16 KB pages
+ if: matrix.ship
+ run: python3 scripts/ci/check-16k-pages.py src/target/release/apk/Concat.apk
+
- name: Build log to the summary (failure only)
if: failure()
run: |
diff --git a/scripts/ci/check-16k-pages.py b/scripts/ci/check-16k-pages.py
new file mode 100755
index 00000000..456fd372
--- /dev/null
+++ b/scripts/ci/check-16k-pages.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+"""Fails when any native library in an APK is not aligned for 16 KB pages.
+
+A phone whose kernel uses 16 KB pages - Android 15 and later can, and
+Google Play requires every app to support it - refuses to load a library
+whose LOAD segments are aligned to less. v0.2.8 shipped
+libconcat_android.so at 4 KB beside three 16 KB libraries.
+
+ scripts/ci/check-16k-pages.py path/to/app.apk
+"""
+import struct
+import sys
+import zipfile
+
+PAGE = 16384
+
+
+def load_alignment(elf: bytes) -> int:
+ if elf[:4] != b"\x7fELF" or elf[4] != 2:
+ raise ValueError("not a 64-bit ELF")
+ phoff = struct.unpack_from("<Q", elf, 0x20)[0]
+ phentsize, phnum = struct.unpack_from("<HH", elf, 0x36)
+ aligns = [
+ struct.unpack_from("<Q", elf, phoff + i * phentsize + 0x30)[0]
+ for i in range(phnum)
+ if struct.unpack_from("<I", elf, phoff + i * phentsize)[0] == 1
+ ]
+ return min(aligns) if aligns else 0
+
+
+def main() -> int:
+ bad = 0
+ with zipfile.ZipFile(sys.argv[1]) as apk:
+ for name in apk.namelist():
+ if not (name.startswith("lib/") and name.endswith(".so")):
+ continue
+ align = load_alignment(apk.read(name))
+ ok = align >= PAGE
+ bad += not ok
+ print(f"{'ok ' if ok else 'BAD'} {align:>6} {name}")
+ if bad:
+ print(f"{bad} librar{'y is' if bad == 1 else 'ies are'} not aligned for 16 KB pages")
+ return 1 if bad else 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/src/scripts/mobile-env.sh b/src/scripts/mobile-env.sh
index cf5d472c..e28013c8 100755
--- a/src/scripts/mobile-env.sh
+++ b/src/scripts/mobile-env.sh
@@ -61,12 +61,20 @@ case "$target" in
# archive under that name, on the search path, is what the linker finds
# instead, and it contributes exactly what the missing library would
# have. The ar magic alone is a well-formed archive with no members.
+ #
+ # Every library the APK carries is linked for 16 KB pages, as FFmpeg's
+ # already is (ffmpeg-mobile.sh): a phone whose kernel uses them refuses
+ # a library aligned to 4 KB, and v0.2.8's libconcat_android.so was.
+ # One RUSTFLAGS for both: cargo reads it whole and ignores the
+ # target's own flags when it is set.
+ rustflags='-C link-arg=-Wl,-z,max-page-size=16384'
if [ "$(uname -s)" = Darwin ]; then
shim=$workspace/vendor/shim/$target
mkdir -p "$shim"
printf '!<arch>\n' > "$shim/libggml-blas.a"
- echo "export RUSTFLAGS='-L native=$shim'"
+ rustflags="$rustflags -L native=$shim"
fi
+ echo "export RUSTFLAGS='$rustflags'"
;;
aarch64-apple-ios)
sherpa=$workspace/vendor/sherpa-onnx/ios/lib