Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Avoid stopping appStartProfiler after application creation ([#3630](https://github.com/getsentry/sentry-java/pull/3630))

*Breaking changes*:

- `options.experimental.sessionReplay.errorSampleRate` was renamed to `options.experimental.sessionReplay.onErrorSampleRate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,14 @@ private void checkCreateTimeOnMain(final @NotNull Application application) {
// if no activity has ever been created, app was launched in background
if (onCreateTime == null) {
appLaunchedInForeground = false;

// we stop the app start profiler, as it's useless and likely to timeout
if (appStartProfiler != null && appStartProfiler.isRunning()) {
appStartProfiler.close();
appStartProfiler = null;
}
}
application.unregisterActivityLifecycleCallbacks(instance);
// we stop the app start profiler, as it's useless and likely to timeout
if (appStartProfiler != null && appStartProfiler.isRunning()) {
appStartProfiler.close();
appStartProfiler = null;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ class AppStartMetricsTest {
verify(profiler).close()
}

@Test
fun `if activity is started, does not stop app start profiler if running`() {
val profiler = mock<ITransactionProfiler>()
whenever(profiler.isRunning).thenReturn(true)
AppStartMetrics.getInstance().appStartProfiler = profiler
AppStartMetrics.getInstance().onActivityCreated(mock(), mock())

AppStartMetrics.getInstance().registerApplicationForegroundCheck(mock())
// Job on main thread checks if activity was launched
Shadows.shadowOf(Looper.getMainLooper()).idle()

verify(profiler, never()).close()
}

@Test
fun `if app start span is longer than 1 minute, appStartTimeSpanWithFallback returns an empty span`() {
val appStartTimeSpan = AppStartMetrics.getInstance().appStartTimeSpan
Expand Down