diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ecbba6f4..7b500b004f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes +- Fix app start spans missing from Pixel devices ([#3634](https://github.com/getsentry/sentry-java/pull/3634)) - Avoid ArrayIndexOutOfBoundsException on Android cpu data collection ([#3598](https://github.com/getsentry/sentry-java/pull/3598)) - Fix lazy select queries instrumentation ([#3604](https://github.com/getsentry/sentry-java/pull/3604)) - Session Replay: buffer mode improvements ([#3622](https://github.com/getsentry/sentry-java/pull/3622)) diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java b/sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java index a220f5eb4a..90c49ed07a 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java @@ -241,6 +241,14 @@ public void registerApplicationForegroundCheck(final @NotNull Application applic isCallbackRegistered = true; appLaunchedInForeground = appLaunchedInForeground || ContextUtils.isForegroundImportance(); application.registerActivityLifecycleCallbacks(instance); + // We post on the main thread a task to post a check on the main thread. On Pixel devices + // (possibly others) the first task posted on the main thread is called before the + // Activity.onCreate callback. This is a workaround for that, so that the Activity.onCreate + // callback is called before the application one. + new Handler(Looper.getMainLooper()).post(() -> checkCreateTimeOnMain(application)); + } + + private void checkCreateTimeOnMain(final @NotNull Application application) { new Handler(Looper.getMainLooper()) .post( () -> {