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

Use App Startup library instead of ContentProvider #1707

Open
minyushov opened this issue Sep 9, 2021 · 11 comments
Open

Use App Startup library instead of ContentProvider #1707

minyushov opened this issue Sep 9, 2021 · 11 comments

Comments

@minyushov
Copy link

Could you please consider using androidx.startup:startup-runtime instead of ContentProvider introduced in #1487?

Jetpack libraries (e.g. WorkManager) are migrating from ContentProvider to App Startup library in order to improve app startup performance and to achieve predictable order of initialization. It would be very nice if Sentry does the same.

Documentation: https://developer.android.com/topic/libraries/app-startup

@bruno-garcia bruno-garcia added Platform: Android enhancement New feature or request labels Sep 9, 2021
@bruno-garcia bruno-garcia added this to To do in kanban via automation Sep 9, 2021
@bruno-garcia bruno-garcia added this to Backlog in Mobile Platform Team Archived via automation Sep 9, 2021
@bruno-garcia bruno-garcia moved this from Backlog to Needs Discussion in Mobile Platform Team Archived Sep 9, 2021
@bruno-garcia
Copy link
Member

I'm not sure we can be adding a dependency to androidx.startup:startup-runtime directly anytime soon but perhaps there's a way to check at runtime if it's available, or have install instructions for users to avoid the content provider and use this approach instead.

@marandaneto thoughts?

@marandaneto
Copy link
Contributor

yep, the problem is depending on the library, when startup-runtime gets popular and implemented by all the android libs, could be possible, not yet.

you can always go for the manual init. https://docs.sentry.io/platforms/android/configuration/manual-init/ and remove the merging of the ContentProvider

@androideveloper
Copy link

This is indeed a nice improvement.

With the current setup, what would be the best way to initialize Sentry first? I'm thinking about increasing the initOrder of the content provider SentryInitProvider. But also curious, why you don't have it in the code similar to SentryPerformanceProvider that is set to 200? Firebase crashlytics has 100 for their content provider.

@romtsn
Copy link
Member

romtsn commented Jun 15, 2022

I'm not sure why we didn't set the priority, @marandaneto knows probably

@marandaneto
Copy link
Contributor

It is set, p2

@romtsn
Copy link
Member

romtsn commented Jun 15, 2022

I meant for the SentryInitProvider the initOrder is not set, do you know why?

@androideveloper
Copy link

I tried that and it it indeed helps init Sentry provider a bit early. But if we have an app start crash in the next content providers, Sentry doesn't have time to upload the logs. See #1643

@marandaneto
Copy link
Contributor

The androidx.startup library uses ContentProvider under the hood:

cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:startup/startup-runtime/src/main/java/androidx/startup/InitializationProvider.java;drc=2f9dd0f2fe4642438ed3f657dc7f901241a16ca8

Yes, but only one instead of N, that's the difference.

@Angelodaniel
Copy link
Member

Hey @kahest is there any progress on this?

@markushi
Copy link
Member

markushi commented Feb 16, 2024

Quick update on this topic, as we recently discussed it.
We'll keep on using a ContentProvider for now, as it allows us to init the SDK early (potentially capturing app start crashes) as well as measuring the app start time.

#1643 has been implemented for a while, meaning if the SDK detects and app start crash it will block execution (even on the main thread) to ensure there's enough time to send the crash report to sentry.io

However, in the long run we plan to move away from using ContentProvider and instead provide our own AppComponentFactory (see #3149)

cc @Angelodaniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Backlog
kanban
To do
Development

No branches or pull requests

9 participants