Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ensure app start type is set, even when ActivityLifecycleIntegration is not running #4216

Open
wants to merge 3 commits into
base: 7.x.x
Choose a base branch
from

Conversation

markushi
Copy link
Member

Fix Ensure app start type is set, even when ActivityLifecycleIntegration is not running or init is deferred.

Fixes getsentry/sentry-react-native#4598

Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 428.61 ms 465.58 ms 36.97 ms
Size 1.70 MiB 2.36 MiB 672.39 KiB

@Override
public void onActivityCreated(
@NotNull Activity activity, @Nullable Bundle savedInstanceState) {
if (appStartMetrics.getAppStartType() == AppStartMetrics.AppStartType.UNKNOWN) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would duplicate the logic of the ActivityLifecycleIntegration
That should save us from a lot of headaches.
Or we can move the logic inside the AppStartMetrics, passing the required uptimeMillis and the Activity Bundle, since it has everything needed to check whether it's a cold or warm start. That way, the code would not even be duplicated, and it would work as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I'd add a comment on why we do this (react native not passing an Application and initializing the SDK too late)

Copy link
Member Author

@markushi markushi Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing, the condition appStartSpan.hasStopped() from ActivityLifecycleIntegration will never evaluate to true within this content provider, causing no warm starts to be detected. This content provider runs before any SDK init, so there's no other component able to stop the span.

Copy link
Member Author

@markushi markushi Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the long I would love to see ActivityLifecycleIntegration being split up into several components:

  • One for app-starts
  • One for profiling
  • One for TTID/TTFD
  • One for activity lifecycle after app-start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants