Skip to content

Commit f4948b2

Browse files
authored
Merge main into 8.x.x with 7.18.0 being latest release (#3920)
* Merge main into 8.x.x with 7.18.0 being latest release * fix SessionCaptureStrategy by copying over from main * deletion from main was missing here * mention main merge in changelog
1 parent e1b0b23 commit f4948b2

File tree

32 files changed

+1988
-75
lines changed

32 files changed

+1988
-75
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Send `otel.kind` to Sentry ([#3907](https://github.com/getsentry/sentry-java/pull/3907))
88
- Allow passing `environment` to `CheckinUtils.withCheckIn` ([3889](https://github.com/getsentry/sentry-java/pull/3889))
9+
- Changes up to `7.18.0` have been merged and are now included as well
910

1011
### Fixes
1112

@@ -59,6 +60,7 @@
5960
- Uses faster Random implementation to generate UUIDs
6061
- Android 15: Add support for 16KB page sizes ([#3851](https://github.com/getsentry/sentry-java/pull/3851))
6162
- See https://developer.android.com/guide/practices/page-sizes for more details
63+
- Changes up to `7.17.0` have been merged and are now included as well
6264

6365
### Fixes
6466

@@ -326,6 +328,29 @@ You may also use `LifecycleHelper.close(token)`, e.g. in case you need to pass t
326328

327329
- Report exceptions returned by Throwable.getSuppressed() to Sentry as exception groups ([#3396] https://github.com/getsentry/sentry-java/pull/3396)
328330

331+
## 7.18.0
332+
333+
### Features
334+
335+
- Android 15: Add support for 16KB page sizes ([#3620](https://github.com/getsentry/sentry-java/pull/3620))
336+
- See https://developer.android.com/guide/practices/page-sizes for more details
337+
- Session Replay: Add `beforeSendReplay` callback ([#3855](https://github.com/getsentry/sentry-java/pull/3855))
338+
- Session Replay: Add support for masking/unmasking view containers ([#3881](https://github.com/getsentry/sentry-java/pull/3881))
339+
340+
### Fixes
341+
342+
- Avoid collecting normal frames ([#3782](https://github.com/getsentry/sentry-java/pull/3782))
343+
- Ensure android initialization process continues even if options configuration block throws an exception ([#3887](https://github.com/getsentry/sentry-java/pull/3887))
344+
- Do not report parsing ANR error when there are no threads ([#3888](https://github.com/getsentry/sentry-java/pull/3888))
345+
- This should significantly reduce the number of events with message "Sentry Android SDK failed to parse system thread dump..." reported
346+
- Session Replay: Disable replay in session mode when rate limit is active ([#3854](https://github.com/getsentry/sentry-java/pull/3854))
347+
348+
### Dependencies
349+
350+
- Bump Native SDK from v0.7.2 to v0.7.8 ([#3620](https://github.com/getsentry/sentry-java/pull/3620))
351+
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#078)
352+
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.2...0.7.8)
353+
329354
## 7.17.0
330355

331356
### Features

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ spotless {
227227
target("**/*.java")
228228
removeUnusedImports()
229229
googleJavaFormat()
230-
targetExclude("**/generated/**", "**/vendor/**")
230+
targetExclude("**/generated/**", "**/vendor/**", "**/sentry-native/**")
231231
}
232232
kotlin {
233233
target("**/*.kt")

sentry-android-core/src/main/java/io/sentry/android/core/AnrV2Integration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,11 @@ private void reportAsSentryEvent(
313313
final ThreadDumpParser threadDumpParser = new ThreadDumpParser(options, isBackground);
314314
final List<SentryThread> threads = threadDumpParser.parse(lines);
315315
if (threads.isEmpty()) {
316-
// if the list is empty this means our regex matching is garbage and this is still error
317-
return new ParseResult(ParseResult.Type.ERROR, dump);
316+
// if the list is empty this means the system failed to capture a proper thread dump of
317+
// the android threads, and only contains kernel-level threads and statuses, those ANRs
318+
// are not actionable and neither they are reported by Google Play Console, so we just
319+
// fall back to not reporting them
320+
return new ParseResult(ParseResult.Type.NO_DUMP);
318321
}
319322
return new ParseResult(ParseResult.Type.DUMP, dump, threads);
320323
} catch (Throwable e) {

sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroid.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ public static void init(
133133
isTimberAvailable,
134134
isReplayAvailable);
135135

136-
configuration.configure(options);
136+
try {
137+
configuration.configure(options);
138+
} catch (Throwable t) {
139+
// let it slip, but log it
140+
options
141+
.getLogger()
142+
.log(
143+
SentryLevel.ERROR,
144+
"Error in the 'OptionsConfiguration.configure' callback.",
145+
t);
146+
}
137147

138148
// if SentryPerformanceProvider was disabled or removed,
139149
// we set the app start / sdk init time here instead

sentry-android-core/src/main/java/io/sentry/android/core/SentryFrameMetrics.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
@ApiStatus.Internal
77
final class SentryFrameMetrics {
88

9-
private int normalFrameCount;
109
private int slowFrameCount;
1110
private int frozenFrameCount;
1211

@@ -18,15 +17,11 @@ final class SentryFrameMetrics {
1817
public SentryFrameMetrics() {}
1918

2019
public SentryFrameMetrics(
21-
final int normalFrameCount,
2220
final int slowFrameCount,
2321
final long slowFrameDelayNanos,
2422
final int frozenFrameCount,
2523
final long frozenFrameDelayNanos,
2624
final long totalDurationNanos) {
27-
28-
this.normalFrameCount = normalFrameCount;
29-
3025
this.slowFrameCount = slowFrameCount;
3126
this.slowFrameDelayNanos = slowFrameDelayNanos;
3227

@@ -47,15 +42,9 @@ public void addFrame(
4742
} else if (isSlow) {
4843
slowFrameDelayNanos += delayNanos;
4944
slowFrameCount += 1;
50-
} else {
51-
normalFrameCount += 1;
5245
}
5346
}
5447

55-
public int getNormalFrameCount() {
56-
return normalFrameCount;
57-
}
58-
5948
public int getSlowFrameCount() {
6049
return slowFrameCount;
6150
}
@@ -72,17 +61,16 @@ public long getFrozenFrameDelayNanos() {
7261
return frozenFrameDelayNanos;
7362
}
7463

75-
public int getTotalFrameCount() {
76-
return normalFrameCount + slowFrameCount + frozenFrameCount;
64+
/** Returns the sum of the slow and frozen frames. */
65+
public int getSlowFrozenFrameCount() {
66+
return slowFrameCount + frozenFrameCount;
7767
}
7868

7969
public long getTotalDurationNanos() {
8070
return totalDurationNanos;
8171
}
8272

8373
public void clear() {
84-
normalFrameCount = 0;
85-
8674
slowFrameCount = 0;
8775
slowFrameDelayNanos = 0;
8876

@@ -95,7 +83,6 @@ public void clear() {
9583
@NotNull
9684
public SentryFrameMetrics duplicate() {
9785
return new SentryFrameMetrics(
98-
normalFrameCount,
9986
slowFrameCount,
10087
slowFrameDelayNanos,
10188
frozenFrameCount,
@@ -110,7 +97,6 @@ public SentryFrameMetrics duplicate() {
11097
@NotNull
11198
public SentryFrameMetrics diffTo(final @NotNull SentryFrameMetrics other) {
11299
return new SentryFrameMetrics(
113-
normalFrameCount - other.normalFrameCount,
114100
slowFrameCount - other.slowFrameCount,
115101
slowFrameDelayNanos - other.slowFrameDelayNanos,
116102
frozenFrameCount - other.frozenFrameCount,
@@ -123,8 +109,7 @@ public SentryFrameMetrics diffTo(final @NotNull SentryFrameMetrics other) {
123109
* to 0
124110
*/
125111
public boolean containsValidData() {
126-
return normalFrameCount >= 0
127-
&& slowFrameCount >= 0
112+
return slowFrameCount >= 0
128113
&& slowFrameDelayNanos >= 0
129114
&& frozenFrameCount >= 0
130115
&& frozenFrameDelayNanos >= 0

sentry-android-core/src/main/java/io/sentry/android/core/SpanFrameMetricsCollector.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void captureFrameMetrics(@NotNull final ISpan span) {
196196
}
197197
}
198198

199-
int totalFrameCount = frameMetrics.getTotalFrameCount();
199+
int totalFrameCount = frameMetrics.getSlowFrozenFrameCount();
200200

201201
final long nextScheduledFrameNanos = frameMetricsCollector.getLastKnownFrameStartTimeNanos();
202202
// nextScheduledFrameNanos might be -1 if no frames have been scheduled for drawing yet
@@ -258,15 +258,17 @@ public void onFrameMetricCollected(
258258
(long) ((double) ONE_SECOND_NANOS / (double) refreshRate);
259259
lastKnownFrameDurationNanos = expectedFrameDurationNanos;
260260

261-
frames.add(
262-
new Frame(
263-
frameStartNanos,
264-
frameEndNanos,
265-
durationNanos,
266-
delayNanos,
267-
isSlow,
268-
isFrozen,
269-
expectedFrameDurationNanos));
261+
if (isSlow || isFrozen) {
262+
frames.add(
263+
new Frame(
264+
frameStartNanos,
265+
frameEndNanos,
266+
durationNanos,
267+
delayNanos,
268+
isSlow,
269+
isFrozen,
270+
expectedFrameDurationNanos));
271+
}
270272
}
271273

272274
private static int interpolateFrameCount(
@@ -281,7 +283,7 @@ private static int interpolateFrameCount(
281283
final long frameMetricsDurationNanos = frameMetrics.getTotalDurationNanos();
282284
final long nonRenderedDuration = spanDurationNanos - frameMetricsDurationNanos;
283285
if (nonRenderedDuration > 0) {
284-
return (int) (nonRenderedDuration / frameDurationNanos);
286+
return (int) Math.ceil((double) nonRenderedDuration / frameDurationNanos);
285287
}
286288
return 0;
287289
}

sentry-android-core/src/test/java/io/sentry/android/core/AnrV2IntegrationTest.kt

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class AnrV2IntegrationTest {
101101
reason: Int? = ApplicationExitInfo.REASON_ANR,
102102
timestamp: Long? = null,
103103
importance: Int? = null,
104-
addTrace: Boolean = true
104+
addTrace: Boolean = true,
105+
addBadTrace: Boolean = false
105106
) {
106107
val builder = ApplicationExitInfoBuilder.newBuilder()
107108
if (reason != null) {
@@ -117,8 +118,36 @@ class AnrV2IntegrationTest {
117118
if (!addTrace) {
118119
return
119120
}
120-
whenever(mock.traceInputStream).thenReturn(
121-
"""
121+
if (addBadTrace) {
122+
whenever(mock.traceInputStream).thenReturn(
123+
"""
124+
Subject: Input dispatching timed out (7985007 com.example.app/com.example.app.ui.MainActivity (server) is not responding. Waited 5000ms for FocusEvent(hasFocus=false))
125+
Here are no Binder-related exception messages available.
126+
Pid(12233) have D state thread(tid:12236 name:Signal Catcher)
127+
128+
129+
RssHwmKb: 823716
130+
RssKb: 548348
131+
RssAnonKb: 382156
132+
RssShmemKb: 13304
133+
VmSwapKb: 82484
134+
135+
136+
--- CriticalEventLog ---
137+
capacity: 20
138+
timestamp_ms: 1731507490032
139+
window_ms: 300000
140+
141+
----- dumping pid: 12233 at 313446151
142+
libdebuggerd_client: unexpected registration response: 0
143+
144+
----- Waiting Channels: pid 12233 at 2024-11-13 19:48:09.980104540+0530 -----
145+
Cmd line: com.example.app:mainProcess
146+
""".trimIndent().byteInputStream()
147+
)
148+
} else {
149+
whenever(mock.traceInputStream).thenReturn(
150+
"""
122151
"main" prio=5 tid=1 Blocked
123152
| group="main" sCount=1 ucsCount=0 flags=1 obj=0x72a985e0 self=0xb400007cabc57380
124153
| sysTid=28941 nice=-10 cgrp=top-app sched=0/0 handle=0x7deceb74f8
@@ -147,8 +176,9 @@ class AnrV2IntegrationTest {
147176
native: #02 pc 00000000000b63b0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 01331f74b0bb2cb958bdc15282b8ec7b)
148177
native: #03 pc 00000000000530b8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 01331f74b0bb2cb958bdc15282b8ec7b)
149178
(no managed stack frames)
150-
""".trimIndent().byteInputStream()
151-
)
179+
""".trimIndent().byteInputStream()
180+
)
181+
}
152182
}
153183
shadowActivityManager.addApplicationExitInfo(exitInfo)
154184
}
@@ -551,4 +581,14 @@ class AnrV2IntegrationTest {
551581

552582
verify(fixture.scopes, never()).captureEvent(any(), anyOrNull<Hint>())
553583
}
584+
585+
@Test
586+
fun `when traceInputStream has bad data, does not report ANR`() {
587+
val integration = fixture.getSut(tmpDir, lastReportedAnrTimestamp = oldTimestamp)
588+
fixture.addAppExitInfo(timestamp = newTimestamp, addBadTrace = true)
589+
590+
integration.register(fixture.scopes, fixture.options)
591+
592+
verify(fixture.scopes, never()).captureEvent(any(), anyOrNull<Hint>())
593+
}
554594
}

sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,19 @@ class SentryAndroidTest {
518518
assertEquals(99, AppStartMetrics.getInstance().appStartTimeSpan.startUptimeMs)
519519
}
520520

521+
@Test
522+
fun `if the config options block throws still intializes android event processors`() {
523+
lateinit var optionsRef: SentryOptions
524+
fixture.initSut(context = mock<Application>()) { options ->
525+
optionsRef = options
526+
options.dsn = "https://[email protected]/123"
527+
throw RuntimeException("Boom!")
528+
}
529+
530+
assertTrue(optionsRef.eventProcessors.any { it is DefaultAndroidEventProcessor })
531+
assertTrue(optionsRef.eventProcessors.any { it is AnrV2EventProcessor })
532+
}
533+
521534
private fun prefillScopeCache(cacheDir: String) {
522535
val scopeDir = File(cacheDir, SCOPE_CACHE).also { it.mkdirs() }
523536
File(scopeDir, BREADCRUMBS_FILENAME).writeText(

sentry-android-core/src/test/java/io/sentry/android/core/SentryFrameMetricsTest.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ import kotlin.test.assertFalse
66
import kotlin.test.assertTrue
77

88
class SentryFrameMetricsTest {
9-
@Test
10-
fun addFastFrame() {
11-
val frameMetrics = SentryFrameMetrics()
12-
frameMetrics.addFrame(10, 0, false, false)
13-
assertEquals(1, frameMetrics.normalFrameCount)
14-
15-
frameMetrics.addFrame(10, 0, false, false)
16-
assertEquals(2, frameMetrics.normalFrameCount)
17-
}
189

1910
@Test
2011
fun addSlowFrame() {
@@ -43,10 +34,12 @@ class SentryFrameMetricsTest {
4334
@Test
4435
fun totalFrameCount() {
4536
val frameMetrics = SentryFrameMetrics()
37+
// Normal frames are ignored
4638
frameMetrics.addFrame(10, 0, false, false)
39+
// Slow and frozen frames are considered
4740
frameMetrics.addFrame(116, 100, true, false)
4841
frameMetrics.addFrame(1016, 1000, true, true)
49-
assertEquals(3, frameMetrics.totalFrameCount)
42+
assertEquals(2, frameMetrics.slowFrozenFrameCount)
5043
}
5144

5245
@Test
@@ -57,12 +50,11 @@ class SentryFrameMetricsTest {
5750
frameMetrics.addFrame(1016, 1000, true, true)
5851

5952
val dup = frameMetrics.duplicate()
60-
assertEquals(1, dup.normalFrameCount)
6153
assertEquals(1, dup.slowFrameCount)
6254
assertEquals(100, dup.slowFrameDelayNanos)
6355
assertEquals(1, dup.frozenFrameCount)
6456
assertEquals(1000, dup.frozenFrameDelayNanos)
65-
assertEquals(3, dup.totalFrameCount)
57+
assertEquals(2, dup.slowFrozenFrameCount)
6658
}
6759

6860
@Test
@@ -89,7 +81,7 @@ class SentryFrameMetricsTest {
8981
assertEquals(1, diff.frozenFrameCount)
9082
assertEquals(1000, diff.frozenFrameDelayNanos)
9183

92-
assertEquals(2, diff.totalFrameCount)
84+
assertEquals(2, diff.slowFrozenFrameCount)
9385
}
9486

9587
@Test
@@ -102,12 +94,11 @@ class SentryFrameMetricsTest {
10294

10395
frameMetrics.clear()
10496

105-
assertEquals(0, frameMetrics.normalFrameCount)
10697
assertEquals(0, frameMetrics.slowFrameCount)
10798
assertEquals(0, frameMetrics.slowFrameDelayNanos)
10899
assertEquals(0, frameMetrics.frozenFrameCount)
109100
assertEquals(0, frameMetrics.frozenFrameDelayNanos)
110-
assertEquals(0, frameMetrics.totalFrameCount)
101+
assertEquals(0, frameMetrics.slowFrozenFrameCount)
111102
}
112103

113104
@Test

0 commit comments

Comments
 (0)