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 lazy initialization causing long startup times #2459

Conversation

wangbax
Copy link

@wangbax wangbax commented Jan 6, 2023

📜 Description

The app needs a sentry to be initialized after the privacy confirmation pop-up box is confirmed, so as to avoid collecting user information in advance.

💡 Motivation and Context

When using performance monitoring, if the initialization is delayed for some reasons (such as the privacy confirmation popup), the startup time will no longer be accurate (although there is a 60s limit).

💚 How did you test it?

  1. Open app
  2. Show privacy confirmation dialog
  3. Wait 30s
  4. Click to confirm,init Sentry,jump to MainActivity

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

@markushi
Copy link
Member

Thanks for opening this PR! Could you give us some more details about your use case?
As you mentioned you initialise the Sentry SDK after a privacy confirmation popup.

  • Did you manually disable the SentryPerformanceProvider? It should be running automatically, even if the SDK has not been initialized yet.

@wangbax
Copy link
Author

wangbax commented Jan 28, 2023

  • Did you manually disable the SentryPerformanceProvider? It should be running automatically, even if the SDK has not been initialized yet.

@markushi thank you for your reply. 😊

The detailed steps are:

  1. Set <meta-data android:name="io.sentry.auto-init" android:value="false" />
  2. In Application onCreate(), judge whether the user has confirmed that he has show the privacy dialog, if true, initialize Sentry, otherwise skip
  3. In SplashActivity (launcher page), judge whether the user has confirmed that he has read the privacy pop-up window. If true, he will enter the HomeActivity (main page). Otherwise, a comfirm dialog will show up. After the confirmation button of the dialog is clicked, Sentry will be initialized
  4. Check startup time

If the SentryPerformanceProvider is blocked, the startup time of the application can only start from the initialization of Sentry, and the time from Application creation to onCreate() will be lost.

I can provide a demo if needed.

@romtsn
Copy link
Member

romtsn commented Jan 30, 2023

ah, so your issue is that we have a limit of 60 seconds for the app startup time, but in your case it actually can take longer, right? What if we just make that 60 seconds threshold configurable instead? So you could set it to 5 minutes (or whatever you think we'll be the longest time your app is gonna show the confirmation dialog)?

@wangbax
Copy link
Author

wangbax commented Feb 3, 2023

actually, i need statistics real app_start_cold time.

image

@markushi
Copy link
Member

markushi commented Feb 6, 2023

@wangbax thanks for clarification! We have found a fix which works across a wider set of edge cases, so I'll close this PR in favor of #2519. The issues itself is tracked as #2518, feel free to follow along and comment.
Thanks again for bringing this up! 👍

@markushi markushi closed this Feb 6, 2023
@wangbax wangbax deleted the wangbax_fix_app_start_too_long_delay_init branch February 10, 2023 12:19
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.

3 participants