Skip to content

Commit 2ff62db

Browse files
committed
Address PR feedback
1 parent 39229d5 commit 2ff62db

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ private void applyAnrProfile(
887887
new ExceptionMechanismException(mechanism, exception, null, false);
888888

889889
final @NotNull List<SentryException> sentryException =
890-
sentryExceptionFactory.getSentryExceptions(exception);
890+
sentryExceptionFactory.getSentryExceptions(error);
891891

892892
// Replace the original ANR exception with the profile-derived one,
893893
// as we assume the profiling culprit identification is more valuable

sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrCulpritIdentifier.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
public class AnrCulpritIdentifier {
1414

1515
// common Java and Android packages who are less relevant for being the actual culprit
16-
private static final List<String> systemAndFrameworkPackages = new ArrayList<>(9);
16+
private static final List<String> systemAndFrameworkPackages = new ArrayList<>(11);
1717

1818
static {
1919
systemAndFrameworkPackages.add("java.lang");
2020
systemAndFrameworkPackages.add("java.util");
21+
2122
systemAndFrameworkPackages.add("android.app");
2223
systemAndFrameworkPackages.add("android.os.Handler");
2324
systemAndFrameworkPackages.add("android.os.Looper");
2425
systemAndFrameworkPackages.add("android.view");
2526
systemAndFrameworkPackages.add("android.widget");
2627
systemAndFrameworkPackages.add("com.android.internal");
2728
systemAndFrameworkPackages.add("com.google.android");
29+
30+
systemAndFrameworkPackages.add("kotlin");
31+
systemAndFrameworkPackages.add("kotlinx.coroutines");
2832
}
2933

3034
private static final class StackTraceKey {

sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfilingIntegration.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
5757
"SentryAndroidOptions is required");
5858
this.logger = options.getLogger();
5959

60-
if (((SentryAndroidOptions) options).isEnableAnrProfiling()) {
61-
if (options.getCacheDirPath() == null) {
60+
if (this.options.isEnableAnrProfiling()) {
61+
if (this.options.getCacheDirPath() == null) {
6262
logger.log(SentryLevel.WARNING, "ANR Profiling is enabled but cacheDirPath is not set");
6363
return;
6464
}
@@ -74,12 +74,30 @@ public void close() throws IOException {
7474
enabled.set(false);
7575
AppState.getInstance().removeAppStateListener(this);
7676

77-
try (final @NotNull ISentryLifecycleToken ignored = profileManagerLock.acquire()) {
78-
final @Nullable AnrProfileManager p = profileManager;
79-
if (p != null) {
80-
p.close();
77+
final @Nullable SentryAndroidOptions opts = options;
78+
if (opts != null) {
79+
try {
80+
opts.getExecutorService()
81+
.submit(
82+
new Runnable() {
83+
@Override
84+
public void run() {
85+
try (final @NotNull ISentryLifecycleToken ignored =
86+
profileManagerLock.acquire()) {
87+
if (profileManager != null) {
88+
//noinspection DataFlowIssue
89+
profileManager.close();
90+
}
91+
} catch (IOException e) {
92+
logger.log(SentryLevel.WARNING, "Failed to close AnrProfileManager");
93+
} finally {
94+
profileManager = null;
95+
}
96+
}
97+
});
98+
} catch (Throwable t) {
99+
logger.log(SentryLevel.WARNING, "Failed to submit AnrProfileManager close");
81100
}
82-
profileManager = null;
83101
}
84102
}
85103

@@ -101,6 +119,7 @@ public void onForeground() {
101119
}
102120

103121
final @NotNull Thread profilingThread = new Thread(this, "AnrProfilingIntegration");
122+
profilingThread.setDaemon(true);
104123
profilingThread.start();
105124
thread = profilingThread;
106125
}

0 commit comments

Comments
 (0)