diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f4f06bda3..a74e690b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +* Fix: Make ActivityFramesTracker operations thread-safe (#1762) * Fix: Clone Scope Contexts (#1763) ## 5.2.2 diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ActivityFramesTracker.java b/sentry-android-core/src/main/java/io/sentry/android/core/ActivityFramesTracker.java index 7e0b6195ff..f6e303acdc 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ActivityFramesTracker.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ActivityFramesTracker.java @@ -47,7 +47,7 @@ private boolean isFrameMetricsAggregatorAvailable() { } @SuppressWarnings("NullAway") - void addActivity(final @NotNull Activity activity) { + synchronized void addActivity(final @NotNull Activity activity) { if (!isFrameMetricsAggregatorAvailable()) { return; } @@ -55,7 +55,7 @@ void addActivity(final @NotNull Activity activity) { } @SuppressWarnings("NullAway") - void setMetrics(final @NotNull Activity activity, final @NotNull SentryId sentryId) { + synchronized void setMetrics(final @NotNull Activity activity, final @NotNull SentryId sentryId) { if (!isFrameMetricsAggregatorAvailable()) { return; } @@ -101,7 +101,8 @@ void setMetrics(final @NotNull Activity activity, final @NotNull SentryId sentry } @Nullable - Map takeMetrics(final @NotNull SentryId sentryId) { + synchronized Map takeMetrics( + final @NotNull SentryId sentryId) { if (!isFrameMetricsAggregatorAvailable()) { return null; } @@ -113,7 +114,7 @@ void setMetrics(final @NotNull Activity activity, final @NotNull SentryId sentry } @SuppressWarnings("NullAway") - void stop() { + synchronized void stop() { if (isFrameMetricsAggregatorAvailable()) { frameMetricsAggregator.stop(); }