Skip to content

RUM-986: Fix crash when disabling JankStats tracking#1596

Merged
0xnm merged 1 commit into
developfrom
nogorodnikov/rum-986/fix-crash-when-disabling-jank-stats-tracking
Sep 4, 2023
Merged

RUM-986: Fix crash when disabling JankStats tracking#1596
0xnm merged 1 commit into
developfrom
nogorodnikov/rum-986/fix-crash-when-disabling-jank-stats-tracking

Conversation

@0xnm

@0xnm 0xnm commented Sep 1, 2023

Copy link
Copy Markdown
Member

What does this PR do?

The following crash was reported by the customer:

java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
        at android.view.View.removeFrameMetricsListener(View.java:7797)
        at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:995)
        at androidx.metrics.performance.DelegatingFrameMetricsListener.remove(JankStatsApi24Impl.kt:253)
        at androidx.metrics.performance.JankStatsApi24Impl.removeFrameMetricsListenerDelegate(JankStatsApi24Impl.kt:126)
        at androidx.metrics.performance.JankStatsApi24Impl.setupFrameTimer(JankStatsApi24Impl.kt:107)
        at androidx.metrics.performance.JankStats.setTrackingEnabled(JankStats.kt:129)
        at com.datadog.android.rum.internal.vitals.JankStatsActivityLifecycleListener.onActivityStopped(JankStatsActivityLifecycleListener.kt:99)
        ....

This PR does the following:

  • Checks that tracking is enabled before disabling it. If it is already disabled - we report it to the telemetry, because probably the issue is on our side.
  • If still there is a crash when we disabling jank stats even in a proper state (when it is enabled) - we still report it to the telemetry, but in this case the problem is in the JankStats class itself probably.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@0xnm
0xnm requested a review from a team as a code owner September 1, 2023 09:08
@0xnm
0xnm force-pushed the nogorodnikov/rum-986/fix-crash-when-disabling-jank-stats-tracking branch 2 times, most recently from 759cc2e to 20dab3f Compare September 1, 2023 09:29
@codecov-commenter

codecov-commenter commented Sep 1, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1596 (cd12e45) into develop (dee218f) will decrease coverage by 0.06%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1596      +/-   ##
===========================================
- Coverage    83.58%   83.52%   -0.06%     
===========================================
  Files          443      443              
  Lines        15122    15135      +13     
  Branches      2264     2265       +1     
===========================================
+ Hits         12639    12641       +2     
- Misses        1885     1892       +7     
- Partials       598      602       +4     
Files Changed Coverage Δ
...ernal/vitals/JankStatsActivityLifecycleListener.kt 88.41% <100.00%> (+2.69%) ⬆️

... and 12 files with indirect coverage changes

@xgouchet xgouchet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch :)

@0xnm
0xnm force-pushed the nogorodnikov/rum-986/fix-crash-when-disabling-jank-stats-tracking branch from 20dab3f to cd12e45 Compare September 1, 2023 14:08
@0xnm
0xnm merged commit 1dfff18 into develop Sep 4, 2023
@0xnm
0xnm deleted the nogorodnikov/rum-986/fix-crash-when-disabling-jank-stats-tracking branch September 4, 2023 07:07
@xgouchet xgouchet added this to the 2.1.0 milestone Dec 13, 2023
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.

5 participants