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

Viewpager adjacent fragments have invalid loadingTime #1295

Open
Albertoperezs90 opened this issue Feb 21, 2023 · 2 comments
Open

Viewpager adjacent fragments have invalid loadingTime #1295

Albertoperezs90 opened this issue Feb 21, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Albertoperezs90
Copy link

Albertoperezs90 commented Feb 21, 2023

Describe what happened
Fragments loaded by viewpager are created when visiting adjacents fragments but if you specify the flag BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT onResume() is not triggered until the fragment is actually visible to the user.

The above behavior is triggering viewLoadingTimer.onCreated() on all the adjacents fragments created, but because onResume() is not called until fragment is visible, the loadingTime is invalid giving bigger values than the real loadingTime.

Steps to reproduce the issue:

  • Create a viewpager and introduce 4 fragments
  • Set an adapter on viewpager with BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT flag.
  • Navigate to fragment 2.
  • Check fragment 3 is created but onResume() is not called
  • After a while, navigate to fragment 3 and check onFragmentResumed is triggered and therefore measuring the loadingTime at this point, making it a bigger value than it should be.

Describe what you expected:

  • ViewLoadingTime should be stopped temporally if fragments belong to viewpager and are not visible to the user.

Additional context

  • Datadog SDK version: com.datadoghq:dd-sdk-android:1.14.0
  • Gradle Plugins: com.datadoghq:dd-sdk-android-gradle-plugin:1.5.1
@Albertoperezs90 Albertoperezs90 added the bug Something isn't working label Feb 21, 2023
@Albertoperezs90 Albertoperezs90 changed the title Viewpager adjacent fragments has invalid loadingTime Viewpager adjacent fragments have invalid loadingTime Feb 22, 2023
@0xnm
Copy link
Contributor

0xnm commented Feb 23, 2023

Hello @Albertoperezs90. Thanks for opening the issue. Indeed, loading time reporting may be not correct because of the delayed lifecycle calls as you've described.

We will try to look at this and see how we can improve reporting.

@Albertoperezs90
Copy link
Author

Thanks @0xnm ! If you need any help, just let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants