SentryFragmentLifecycleCallbacks creates long running spans for ViewPager2
Integration
sentry-android
Build System
Gradle
AGP Version
unknown
Proguard
Enabled
Version
unknown
Steps to Reproduce
- Use ViewPager2
- Enable performance and our FragmentLifecycleIntegration
Expected Result
No span is created for non-visible fragments.
Actual Result
A span is created, but due to this:
non-primary-item Fragments are capped at STARTED
the spans end up running into an timeout, causing extra long transaction durations.
We probably should be using getUserVisibleHint() or getMinimumMaxLifecycleState() to determine Fragments which won't be activated.
┆Issue is synchronized with this Jira Improvement by Unito
@markushi any updates on this? I added a report from an enterprise customer in the linked Jira ticket. They believe the same issue is affecting their TTID.
cc @stefanosiano
we are going to take a look at this in the next week
Hi @stefanosiano, were you guys able to make any progress on this one?
Hi @realkosty I was having some problem, but now I'm finally able to reproduce it and working on it 👍
Options considered:
- getUserVisibleHint(): it's deprecated and returns true for all fragments
- mMaxState: only accessible through reflection and returns the current max state achieved (in
onFragmentStartedit will be STARTED, while inonFragmentResumedit will be RESUMED - isVisible: returns true for all fragments
It seems like the only real option for us is to stop the span in onFragmentStarted instead of onFragmentResumed. Breadcrumbs will still be created correctly and most operations are going to be in Fragment.onCreate and associated callbacks, so it should be fine for users.