Skip to content

Commit 32eed6a

Browse files
authored
Fix app start spans missing from Pixel devices (#3634)
* added post on main thread to post check on main thread
1 parent 19d98e8 commit 32eed6a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Fixes
1010

11+
- Fix app start spans missing from Pixel devices ([#3634](https://github.com/getsentry/sentry-java/pull/3634))
1112
- Avoid ArrayIndexOutOfBoundsException on Android cpu data collection ([#3598](https://github.com/getsentry/sentry-java/pull/3598))
1213
- Fix lazy select queries instrumentation ([#3604](https://github.com/getsentry/sentry-java/pull/3604))
1314
- Session Replay: buffer mode improvements ([#3622](https://github.com/getsentry/sentry-java/pull/3622))

sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ public void registerApplicationForegroundCheck(final @NotNull Application applic
241241
isCallbackRegistered = true;
242242
appLaunchedInForeground = appLaunchedInForeground || ContextUtils.isForegroundImportance();
243243
application.registerActivityLifecycleCallbacks(instance);
244+
// We post on the main thread a task to post a check on the main thread. On Pixel devices
245+
// (possibly others) the first task posted on the main thread is called before the
246+
// Activity.onCreate callback. This is a workaround for that, so that the Activity.onCreate
247+
// callback is called before the application one.
248+
new Handler(Looper.getMainLooper()).post(() -> checkCreateTimeOnMain(application));
249+
}
250+
251+
private void checkCreateTimeOnMain(final @NotNull Application application) {
244252
new Handler(Looper.getMainLooper())
245253
.post(
246254
() -> {

0 commit comments

Comments
 (0)