diff --git a/CHANGELOG.md b/CHANGELOG.md index a1f7a02cd3..b6c48996b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,9 +64,9 @@ ### Dependencies -- Bump Native SDK from v0.7.5 to v0.7.8 ([#3851](https://github.com/getsentry/sentry-java/pull/3851)) - - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#078) - - [diff](https://github.com/getsentry/sentry-native/compare/0.7.5...0.7.8) +- Bump Native SDK from v0.7.5 to v0.7.14 ([#3851](https://github.com/getsentry/sentry-java/pull/3851)) ([#3914](https://github.com/getsentry/sentry-java/pull/3914)) + - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0714) + - [diff](https://github.com/getsentry/sentry-native/compare/0.7.5...0.7.14) ### Behavioural Changes diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 52bc576eaf..dd62348342 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -153,7 +153,7 @@ object Config { val apolloKotlin = "com.apollographql.apollo3:apollo-runtime:3.8.2" - val sentryNativeNdk = "io.sentry:sentry-native-ndk:0.7.8" + val sentryNativeNdk = "io.sentry:sentry-native-ndk:0.7.14" object OpenTelemetry { val otelVersion = "1.41.0" diff --git a/scripts/update-sentry-native-ndk.sh b/scripts/update-sentry-native-ndk.sh index 544dc403ac..347e5df921 100755 --- a/scripts/update-sentry-native-ndk.sh +++ b/scripts/update-sentry-native-ndk.sh @@ -2,8 +2,7 @@ set -euo pipefail cd $(dirname "$0")/../ -GRADLE_NDK_FILEPATH=sentry-android-ndk/build.gradle.kts -GRADLE_SAMPLE_FILEPATH=sentry-samples/sentry-samples-android/build.gradle.kts +GRADLE_NDK_FILEPATH=buildSrc/src/main/java/Config.kt case $1 in get-version) @@ -26,7 +25,6 @@ set-version) PATTERN="io\.sentry:sentry-native-ndk:([0-9.]+)+" perl -pi -e "s/$PATTERN/io.sentry:sentry-native-ndk:$version/g" $GRADLE_NDK_FILEPATH - perl -pi -e "s/$PATTERN/io.sentry:sentry-native-ndk:$version/g" $GRADLE_SAMPLE_FILEPATH ;; *) echo "Unknown argument $1" diff --git a/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java b/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java index ebce1a12fd..a37475002e 100644 --- a/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java +++ b/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java @@ -3,14 +3,33 @@ import io.sentry.android.core.SentryAndroidOptions; import io.sentry.ndk.NativeModuleListLoader; import io.sentry.ndk.NdkOptions; +import io.sentry.util.Objects; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @ApiStatus.Internal public final class SentryNdk { + private static final @NotNull CountDownLatch loadLibraryLatch = new CountDownLatch(1); + private SentryNdk() {} + static { + new Thread( + () -> { + try { + //noinspection UnstableApiUsage + io.sentry.ndk.SentryNdk.loadNativeLibraries(); + } finally { + loadLibraryLatch.countDown(); + } + }, + "SentryNdkLoadLibs") + .start(); + } + /** * Init the NDK integration * @@ -18,29 +37,50 @@ private SentryNdk() {} */ public static void init(@NotNull final SentryAndroidOptions options) { SentryNdkUtil.addPackage(options.getSdkVersion()); + try { + if (loadLibraryLatch.await(2000, TimeUnit.MILLISECONDS)) { + final @NotNull NdkOptions ndkOptions = + new NdkOptions( + Objects.requireNonNull(options.getDsn(), "DSN is required for sentry-ndk"), + options.isDebug(), + Objects.requireNonNull( + options.getOutboxPath(), "outbox path is required for sentry-ndk"), + options.getRelease(), + options.getEnvironment(), + options.getDist(), + options.getMaxBreadcrumbs(), + options.getNativeSdkName()); - final @NotNull NdkOptions ndkOptions = - new NdkOptions( - options.getDsn(), - options.isDebug(), - options.getOutboxPath(), - options.getRelease(), - options.getEnvironment(), - options.getDist(), - options.getMaxBreadcrumbs(), - options.getNativeSdkName()); - io.sentry.ndk.SentryNdk.init(ndkOptions); - - // only add scope sync observer if the scope sync is enabled. - if (options.isEnableScopeSync()) { - options.addScopeObserver(new NdkScopeObserver(options)); - } + //noinspection UnstableApiUsage + io.sentry.ndk.SentryNdk.init(ndkOptions); - options.setDebugImagesLoader(new DebugImagesLoader(options, new NativeModuleListLoader())); + // only add scope sync observer if the scope sync is enabled. + if (options.isEnableScopeSync()) { + options.addScopeObserver(new NdkScopeObserver(options)); + } + + options.setDebugImagesLoader(new DebugImagesLoader(options, new NativeModuleListLoader())); + } else { + throw new IllegalStateException("Timeout waiting for Sentry NDK library to load"); + } + } catch (InterruptedException e) { + throw new IllegalStateException( + "Thread interrupted while waiting for NDK libs to be loaded", e); + } } /** Closes the NDK integration */ public static void close() { - io.sentry.ndk.SentryNdk.close(); + try { + if (loadLibraryLatch.await(2000, TimeUnit.MILLISECONDS)) { + //noinspection UnstableApiUsage + io.sentry.ndk.SentryNdk.close(); + } else { + throw new IllegalStateException("Timeout waiting for Sentry NDK library to load"); + } + } catch (InterruptedException e) { + throw new IllegalStateException( + "Thread interrupted while waiting for NDK libs to be loaded", e); + } } } diff --git a/sentry-samples/sentry-samples-android/build.gradle.kts b/sentry-samples/sentry-samples-android/build.gradle.kts index 1c1f565bd9..88ee38e931 100644 --- a/sentry-samples/sentry-samples-android/build.gradle.kts +++ b/sentry-samples/sentry-samples-android/build.gradle.kts @@ -16,7 +16,10 @@ android { externalNativeBuild { cmake { - arguments.add(0, "-DANDROID_STL=c++_shared") + // Android 15: As we're using an older version of AGP / NDK, the STL is not 16kb page aligned yet + // Our example code doesn't use the STL, so we simply disable it + // See https://developer.android.com/guide/practices/page-sizes + arguments.add(0, "-DANDROID_STL=none") } }