From 256b338ae3576aaa6a9995d6a5bdbd40ca16cb6d Mon Sep 17 00:00:00 2001 From: billisdead Date: Mon, 22 Jun 2026 14:23:38 +0200 Subject: [PATCH] fix: patch worklets and reanimated for Android 15 16KB page size support react-native-worklets and react-native-reanimated compile .so files without -Wl,-z,max-page-size=16384, causing a native crash at startup on Android 15 devices that use 16KB memory pages (Pixel 9+, Galaxy S25+). Patch applied in build-apk.sh and CI workflow after npm install, before the Gradle build. Guard prevents double-patching on repeated runs. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/build-android.yml | 11 +++++++++++ build-apk.sh | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 29cbdaf..a9e88d4 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -89,6 +89,17 @@ jobs: [ -n "$KEYSTORE_STORE_PASSWORD" ] && echo "KEYSTORE_STORE_PASSWORD: set" || echo "KEYSTORE_STORE_PASSWORD: EMPTY" [ -n "$KEYSTORE_KEY_PASSWORD" ] && echo "KEYSTORE_KEY_PASSWORD: set" || echo "KEYSTORE_KEY_PASSWORD: EMPTY" + - name: Patch native modules for Android 15 16KB page size + run: | + WORKLETS="node_modules/react-native-worklets/android/CMakeLists.txt" + REANIMATED="node_modules/react-native-reanimated/android/CMakeLists.txt" + if [ -f "$WORKLETS" ] && ! grep -q "max-page-size" "$WORKLETS"; then + printf '\ntarget_link_options(worklets PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$WORKLETS" + fi + if [ -f "$REANIMATED" ] && ! grep -q "max-page-size" "$REANIMATED"; then + printf '\ntarget_link_options(reanimated PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$REANIMATED" + fi + - name: Build signed APK run: ./build-apk.sh diff --git a/build-apk.sh b/build-apk.sh index 5544ea5..f5256bb 100755 --- a/build-apk.sh +++ b/build-apk.sh @@ -77,6 +77,22 @@ info "Running expo prebuild (Android)…" cd "$SCRIPT_DIR" npx expo prebuild --platform android --clean --no-install +# ─── 4.5. Patch native modules — 16KB page size (Android 15) ────────────── +info "Patching native modules for 16KB page size support (Android 15)…" + +WORKLETS_CMAKE="$SCRIPT_DIR/node_modules/react-native-worklets/android/CMakeLists.txt" +REANIMATED_CMAKE="$SCRIPT_DIR/node_modules/react-native-reanimated/android/CMakeLists.txt" + +if [ -f "$WORKLETS_CMAKE" ] && ! grep -q "max-page-size" "$WORKLETS_CMAKE"; then + printf '\ntarget_link_options(worklets PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$WORKLETS_CMAKE" + info "Patched react-native-worklets for 16KB pages" +fi + +if [ -f "$REANIMATED_CMAKE" ] && ! grep -q "max-page-size" "$REANIMATED_CMAKE"; then + printf '\ntarget_link_options(reanimated PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$REANIMATED_CMAKE" + info "Patched react-native-reanimated for 16KB pages" +fi + # ─── 5. Patch build.gradle — inject release signingConfig ────────────────── info "Patching android/app/build.gradle for release signing…"