diff --git a/.github/workflows/sample-application.yml b/.github/workflows/sample-application.yml index efb32a6d89..24bc5d46ac 100644 --- a/.github/workflows/sample-application.yml +++ b/.github/workflows/sample-application.yml @@ -199,12 +199,24 @@ jobs: [[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='release' || export CONFIG='debug' ./scripts/set-dsn-aos.mjs - # Build all ABIs (not just x86) so armeabi-v7a and the 64-bit ABIs are - # exercised too. The Sentry perf-logger native library is compiled from - # source per ABI, and ABI-specific breakage has shipped before (#6394 - # 16 KB alignment, #6398 armeabi-v7a link) precisely because CI only - # built x86. The 16 KB alignment check below then runs across every ABI. - ./scripts/build-android.sh -PreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + # Split ABI coverage across the two matrix entries: + # - `dev` → subset (arm64-v8a only) so we can assert the module + # builds only the ABIs the app requested — the root + # cause of #6398 was hardcoded abiFilters ignoring + # `reactNativeArchitectures`. + # - `production` → all four ABIs so the 16 KB alignment check below + # runs across every ABI (guards against #6394). + if [[ "${{ matrix.build-type }}" == "production" ]]; then + ./scripts/build-android.sh -PreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + else + ./scripts/build-android.sh -PreactNativeArchitectures=arm64-v8a + fi + + - name: Check libsentry-tm-perf-logger.so honors reactNativeArchitectures + if: ${{ matrix.build-type == 'dev' }} + # Asserts the module packaged our .so for exactly the subset the app + # requested — guards against regressing the #6398 root-cause fix. + run: ./scripts/check-tm-perf-logger-abi-subset.sh ${{ env.REACT_NATIVE_SAMPLE_PATH }}/app.apk 'arm64-v8a' - name: Check 16 KB native library alignment # Only Sentry-owned libraries are checked: third-party/React Native diff --git a/scripts/check-tm-perf-logger-abi-subset.sh b/scripts/check-tm-perf-logger-abi-subset.sh new file mode 100755 index 0000000000..767072780a --- /dev/null +++ b/scripts/check-tm-perf-logger-abi-subset.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Regression guard for the `reactNativeArchitectures` fix in +# https://github.com/getsentry/sentry-react-native/issues/6398. +# +# `libsentry-tm-perf-logger.so` is compiled from source in the consuming app. +# `packages/core/android/build.gradle` must honour the host app's +# `reactNativeArchitectures` property (like react-native-screens / reanimated +# do) so the module builds only the ABIs the app requested. When it doesn't, +# the module builds ABIs whose React Native `reactnative` prefab isn't +# provided → link failure. +# +# This check asserts that a built APK contains `libsentry-tm-perf-logger.so` +# for EXACTLY the ABIs the app requested — no more, no less. Point it at a +# clean-build APK from a subset-ABI build (e.g. `-PreactNativeArchitectures=arm64-v8a`). +# +# Usage: scripts/check-tm-perf-logger-abi-subset.sh +# e.g. scripts/check-tm-perf-logger-abi-subset.sh app.apk 'arm64-v8a' + +set -euo pipefail + +apk="${1:-}" +expected_csv="${2:-}" +if [[ -z "$apk" || ! -f "$apk" || -z "$expected_csv" ]]; then + echo "usage: $0 " >&2 + exit 2 +fi + +workdir="$(mktemp -d)" +trap 'rm -rf "$workdir"' EXIT + +# Extract only the native libraries. APK stores them under `lib/`, AAB under `base/lib/`. +unzip -qq -o "$apk" 'lib/*' 'base/lib/*' -d "$workdir" 2>/dev/null || true + +# ABIs where our library was packaged, one per line, sorted, unique. +actual=$( + find "$workdir" -type f -name 'libsentry-tm-perf-logger.so' 2>/dev/null \ + | sed -E 's|.*/lib/([^/]+)/.*|\1|' \ + | sort -u +) +expected=$(echo "$expected_csv" | tr ',' '\n' | sed '/^$/d' | sort -u) + +echo "expected ABIs: $(echo $expected | tr '\n' ' ')" +echo "actual ABIs: $(echo $actual | tr '\n' ' ')" + +if [[ -z "$actual" ]]; then + echo "✖ libsentry-tm-perf-logger.so not found in $apk" >&2 + echo " Expected it packaged for: $(echo $expected | tr '\n' ' ')" >&2 + exit 1 +fi + +if [[ "$actual" != "$expected" ]]; then + echo "✖ ABI mismatch — module built ABIs the app did not request (or missed one)." >&2 + echo " Root cause of #6398: abiFilters not honoring reactNativeArchitectures." >&2 + exit 1 +fi + +echo "✔ libsentry-tm-perf-logger.so packaged for exactly the requested ABI(s)"