DataDog / dd-sdk-android

Datadog SDK for Android (Compatible with Kotlin and Java)
Apache License 2.0
140 stars 56 forks source link

Crash gets assigned to wrong view #2074

Closed satyajitvure91 closed 1 month ago

satyajitvure91 commented 1 month ago

Describe the bug

I've tried simulating a crash on a fragment and observed that the crash gets assigned to another fragment that precedes the actual fragment where the crash occurred.

Reproduction steps

  1. Simulate a crash in onCreate of a fragment.
  2. Launch app
  3. Navigate to the fragment in step 1
  4. App crashes
  5. Relaunch the app
  6. RUM dashboard assigns the crash to fragment that precedes the fragment where crash occurred

Logcat logs

No response

Expected behavior

Crash should be registered under correct rum view

Affected SDK versions

2.8.0

Latest working SDK version

2.8.0

Did you confirm if the latest SDK version fixes the bug?

No

Kotlin / Java version

No response

Gradle / AGP version

No response

Other dependencies versions

No response

Device Information

No response

Other relevant information

No response

xgouchet commented 1 month ago

Hi @satyajitvure91 , the tracking of Fragments as RUM views are tied to the fragment's onResume() lifecycle callback. Indeed, a fragment could be created and not displayed for a while (e.g. in a view pager). If the crash happens in the onCreate() of your fragment, it'll be attached to the last displayed fragment, which is the previous one.