Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1

# DO NOT MERGE (remove after releasing getsentry/sentry-native#2301)
- name: Checkout sentry-native
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: getsentry/sentry-native
ref: jpnurmi/fix/native-android-21
path: sentry-native
submodules: 'recursive'

# DO NOT MERGE (remove after releasing getsentry/sentry-native#2301)
- name: Publish sentry-native-ndk-outproc to Maven Local
working-directory: sentry-native/ndk
run: ./gradlew --no-daemon -PversionName=0.0.0-local :sentry-native-ndk-outproc:publishToMavenLocal

- name: Run Tests and Lint
run: make preMerge

Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

> [!WARNING]
> SDK 9.0.0 will raise the minimum supported Java and Android versions:
>
> - Java 8 support will be dropped. SDK 9.0.0 requires Java 11+. See [#6469](https://github.com/getsentry/sentry-java/issues/6469).
> - The Android `minSdk` will be raised from 21 to 24. See [#5508](https://github.com/getsentry/sentry-java/issues/5508).

## Future (TODO: release sentry-native#2301)

### Fixes

- Android: Out-of-process crash reporting now supports Android 5.0 (API level 21) and later, previously required Android 11 (API level 30) ([#6614](https://github.com/getsentry/sentry-java/pull/6614))

## Unreleased

### Fixes
Expand Down Expand Up @@ -495,7 +502,7 @@
- Use Android's `ProfilingManager` (Perfetto) for continuous profiling on API 35+ devices ([#5251](https://github.com/getsentry/sentry-java/pull/5251))
- On API 35+ devices, continuous profiling now automatically uses Android's system `ProfilingManager` with Perfetto-based stack sampling, providing lower-overhead and more accurate profiles. No configuration change is required.
- Devices below API 35 keep using the legacy `Debug`-based profiler.
- Added an `enableLegacyProfiling` option (default `true`) to disable the legacy `Debug`-based profiler. Setting it to `false` disables continuous profiling on API < 35 devices as well as transaction-based profiling (`profilesSampleRate`/`profilesSampler`) on all devices, since transaction-based profiling is not supported by Perfetto.
- Added an `enableLegacyProfiling` option (default `true`) to disable the legacy `Debug`-based profiler. Setting it to `false` disables continuous profiling on API < 35 devices as well as transaction-based profiling (`profilesSampleRate`/`profilesSampler`) on all devices, since transaction-based profiling is not supported by Perfetto.
- It can also be configured via the `io.sentry.profiling.enable-legacy-profiling` manifest flag.
- See the [Android profiling docs](https://docs.sentry.io/platforms/android/profiling/) for details.

Expand Down Expand Up @@ -637,6 +644,7 @@

Sentry.finishExtendedAppStart()
```

- Add `trace_metric_byte` data category and record byte-level client reports when trace metrics are discarded ([#5626](https://github.com/getsentry/sentry-java/pull/5626))
- Expose sentry-native's heartbeat-based app-hang detection through `SentryAndroidOptions` ([#5623](https://github.com/getsentry/sentry-java/pull/5623))
- Enable via `setEnableNdkAppHangTracking(true)` (disabled by default) and tune the timeout with `setNdkAppHangTimeoutIntervalMillis(...)` (default `5000` ms), or the `io.sentry.ndk.app-hang.enable` / `io.sentry.ndk.app-hang.timeout-interval-millis` manifest entries
Expand Down Expand Up @@ -830,6 +838,7 @@
}
}
```

- Parse ART memory and garbage collector info from ANR tombstones into ART context ([#5428](https://github.com/getsentry/sentry-java/pull/5428))

## 8.42.0
Expand All @@ -839,7 +848,7 @@
- Add option to attach raw tombstone protobuf on native crash events ([#5446](https://github.com/getsentry/sentry-java/pull/5446))
- Enable via `options.isAttachRawTombstone = true` or manifest: `<meta-data android:name="io.sentry.tombstone.attach-raw" android:value="true" />`
- Add API to clear feature flags from scopes ([#5426](https://github.com/getsentry/sentry-java/pull/5426))
- Add support to configure reporting historical ANRs via `AndroidManifest.xml` using the `io.sentry.anr.report-historical` attribute ([#5387](https://github.com/getsentry/sentry-java/pull/5387))
- Add support to configure reporting historical ANRs via `AndroidManifest.xml` using the `io.sentry.anr.report-historical` attribute ([#5387](https://github.com/getsentry/sentry-java/pull/5387))

### Dependencies

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ reactor-core = { module = "io.projectreactor:reactor-core", version = "3.5.3" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
sentry-native-ndk = { module = "io.sentry:sentry-native-ndk", version = "0.17.6" }
sentry-native-ndk-outproc = { module = "io.sentry:sentry-native-ndk-outproc", version = "1.0.0-beta.1" }
sentry-native-ndk-outproc = { module = "io.sentry:sentry-native-ndk-outproc", version = "0.0.0-local" }
servlet-api = { module = "javax.servlet:javax.servlet-api", version = "3.1.0" }
servlet4-api = { module = "javax.servlet:javax.servlet-api", version = "4.0.1" }
servlet-jakarta-api = { module = "jakarta.servlet:jakarta.servlet-api", version = "6.1.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import io.sentry.android.fragment.FragmentLifecycleIntegration;
import io.sentry.android.timber.SentryTimberIntegration;
import io.sentry.util.AutoClosableReentrantLock;
import io.sentry.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -290,13 +293,30 @@ private static void deduplicateIntegrations(
}
}

// the crash service only runs on API 30+
@SuppressLint("NewApi")
private static boolean isNdkCrashServiceProcess() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if (!new io.sentry.util.LoadClass()
.isClassAvailable(NdkIntegration.SENTRY_NDK_OUTPROC_CLASS_NAME, (ILogger) null)) {
return false;
}
final @Nullable String processName = Application.getProcessName();
final @Nullable String processName =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
? Application.getProcessName()
: readProcessName();
Comment thread
jpnurmi marked this conversation as resolved.
Resolved
return processName != null && processName.endsWith(NDK_CRASH_SERVICE_PROCESS_SUFFIX);
}

// argv[0] of an app process is its process name
private static @Nullable String readProcessName() {
try {
final @Nullable String cmdline = FileUtils.readText(new File("/proc/self/cmdline"));
if (cmdline == null) {
return null;
}
final int end = cmdline.indexOf('\0');
return end >= 0 ? cmdline.substring(0, end) : cmdline;
} catch (IOException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import io.sentry.protocol.Contexts
import io.sentry.spotlight.SpotlightIntegration
import io.sentry.test.applyTestOptions
import io.sentry.transport.NoOpEnvelopeCache
import io.sentry.util.LoadClass
import io.sentry.util.StringUtils
import java.io.ByteArrayOutputStream
import java.io.File
Expand All @@ -72,6 +73,7 @@ import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.mockito.Mockito
import org.mockito.kotlin.any
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
Expand Down Expand Up @@ -580,12 +582,35 @@ class SentryAndroidTest {
ShadowApplication.setProcessName("${context.packageName}.sentry_ndk_crash")
var configured = false

fixture.initSut { configured = true }
Mockito.mockConstruction(LoadClass::class.java) { loadClass, _ ->
whenever(
loadClass.isClassAvailable(
eq(NdkIntegration.SENTRY_NDK_OUTPROC_CLASS_NAME),
anyOrNull<ILogger>(),
),
)
.thenReturn(true)
}
.use { fixture.initSut { configured = true } }

assertFalse(configured)
assertFalse(Sentry.isEnabled())
}

@Test
@Config(sdk = [30])
fun `init runs in a process named like the NDK crash service without outproc`() {
ShadowApplication.setProcessName("${context.packageName}.sentry_ndk_crash")
var configured = false

fixture.initSut {
it.dsn = "https://key@sentry.io/123"
configured = true
}

assertTrue(configured)
}

private fun prefillScopeCache(options: SentryOptions, cacheDir: String) {
val scopeDir = File(cacheDir, SCOPE_CACHE).also { it.mkdirs() }
val queueFile = QueueFile.Builder(File(scopeDir, BREADCRUMBS_FILENAME)).build()
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-ndk-outproc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ configurations.configureEach {
```

Otherwise, the build fails because it contains both native backends.

The crash service needs API 30+. On older versions, native crash reporting is
disabled.
Loading
Loading