File tree 3 files changed +21
-5
lines changed
main/java/io/sentry/android/core/performance
test/java/io/sentry/android/core/performance
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Fixes
6
6
7
+ - Avoid stopping appStartProfiler after application creation ([ #3630 ] ( https://github.com/getsentry/sentry-java/pull/3630 ) )
7
8
- Avoid ArrayIndexOutOfBoundsException on Android cpu data collection ([ #3598 ] ( https://github.com/getsentry/sentry-java/pull/3598 ) )
8
9
- Fix lazy select queries instrumentation ([ #3604 ] ( https://github.com/getsentry/sentry-java/pull/3604 ) )
9
10
Original file line number Diff line number Diff line change @@ -247,13 +247,14 @@ public void registerApplicationForegroundCheck(final @NotNull Application applic
247
247
// if no activity has ever been created, app was launched in background
248
248
if (onCreateTime == null ) {
249
249
appLaunchedInForeground = false ;
250
+
251
+ // we stop the app start profiler, as it's useless and likely to timeout
252
+ if (appStartProfiler != null && appStartProfiler .isRunning ()) {
253
+ appStartProfiler .close ();
254
+ appStartProfiler = null ;
255
+ }
250
256
}
251
257
application .unregisterActivityLifecycleCallbacks (instance );
252
- // we stop the app start profiler, as it's useless and likely to timeout
253
- if (appStartProfiler != null && appStartProfiler .isRunning ()) {
254
- appStartProfiler .close ();
255
- appStartProfiler = null ;
256
- }
257
258
});
258
259
}
259
260
Original file line number Diff line number Diff line change @@ -196,6 +196,20 @@ class AppStartMetricsTest {
196
196
verify(profiler).close()
197
197
}
198
198
199
+ @Test
200
+ fun `if activity is started, does not stop app start profiler if running` () {
201
+ val profiler = mock<ITransactionProfiler >()
202
+ whenever(profiler.isRunning).thenReturn(true )
203
+ AppStartMetrics .getInstance().appStartProfiler = profiler
204
+ AppStartMetrics .getInstance().onActivityCreated(mock(), mock())
205
+
206
+ AppStartMetrics .getInstance().registerApplicationForegroundCheck(mock())
207
+ // Job on main thread checks if activity was launched
208
+ Shadows .shadowOf(Looper .getMainLooper()).idle()
209
+
210
+ verify(profiler, never()).close()
211
+ }
212
+
199
213
@Test
200
214
fun `if app start span is longer than 1 minute, appStartTimeSpanWithFallback returns an empty span` () {
201
215
val appStartTimeSpan = AppStartMetrics .getInstance().appStartTimeSpan
You can’t perform that action at this time.
0 commit comments