Skip to content

fix: Add internal disableJankStats config option#3000

Merged
awforsythe merged 3 commits into
developfrom
aforsythe/RUM-12763/disable-jank-stats
Nov 12, 2025
Merged

fix: Add internal disableJankStats config option#3000
awforsythe merged 3 commits into
developfrom
aforsythe/RUM-12763/disable-jank-stats

Conversation

@awforsythe

Copy link
Copy Markdown
Contributor

refs: RUM-12763

What does this PR do?

This PR adds a check to RUM feature initialization: if the new internal option _dd.rum.disable_jank_stats is explicitly set to true, then we refrain from calling initializeFrameStatesAggregator(). Otherwise, we call that function as normal.

Motivation

This change allows the Unity SDK to configure the Android SDK in such a way that it will never call JankStats.createAndTrack(), which is necessary to avoid crashes caused by the older versions of androidx.metrics that the dd-sdk-unity is forced to use in older versions of Unity.

Additional Notes

I notice that the generated apiSurface files are not up to date at latest in develop, so I expect that CI will fail. When I test locally with ./local-ci.sh --test, everything passes. I can rebase once the unrelated API surface issue is fixed in develop.

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)

refs: RUM-12763

This PR adds a check to RUM feature initialization: if the new internal
option `_dd.rum.disable_jank_stats` is explicitly set to true, then we
refrain from calling `initializeFrameStatesAggregator()`. Otherwise, we
call that function as normal.

This allows the Unity SDK to configure the Android SDK in such a way
that it will never call `JankStats.createAndTrack()`, which is necessary
to avoid crashes caused by the older versions of `androidx.metrics` that
the `dd-sdk-unity` is forced to use in older versions of Unity.

(I notice that the generated `apiSurface` files are not up to date at
latest in develop, so I expect that CI will fail. When I test locally
with `./local-ci.sh --test`, everything passes. I can rebase once the
unrelated API surface issue is fixed in develop.)
@awforsythe
awforsythe requested review from a team as code owners November 11, 2025 21:13
awforsythe added a commit to DataDog/dd-sdk-unity that referenced this pull request Nov 11, 2025
refs: RUM-12764

This PR updates Android RUM initialization logic such that we always set
`_dd.rum.disable_jank_stats` to `true` when configuring `dd-sdk-android`.

This change depends on [an accompanying dd-sdk-android fix](DataDog/dd-sdk-android#3000),
which will need to be released in v2. We'll need to bump the Unity SDK's
dd-sdk-android dependency once that release is available.
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 11, 2025

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 62.50%
Total Coverage: 71.22% (+0.11%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 63c16f0 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter

codecov-commenter commented Nov 11, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.25%. Comparing base (d96dcda) to head (63c16f0).
⚠️ Report is 1109 commits behind head on develop.

Files with missing lines Patch % Lines
...kotlin/com/datadog/android/rum/RumConfiguration.kt 0.00% 2 Missing ⚠️
...otlin/com/datadog/android/rum/_RumInternalProxy.kt 0.00% 1 Missing ⚠️
...lin/com/datadog/android/rum/internal/RumFeature.kt 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3000      +/-   ##
===========================================
- Coverage    71.34%   71.25%   -0.09%     
===========================================
  Files          859      859              
  Lines        31309    31320      +11     
  Branches      5275     5276       +1     
===========================================
- Hits         22335    22316      -19     
- Misses        7505     7528      +23     
- Partials      1469     1476       +7     
Files with missing lines Coverage Δ
...otlin/com/datadog/android/rum/_RumInternalProxy.kt 70.00% <0.00%> (-3.68%) ⬇️
...lin/com/datadog/android/rum/internal/RumFeature.kt 89.86% <90.00%> (-0.17%) ⬇️
...kotlin/com/datadog/android/rum/RumConfiguration.kt 93.98% <0.00%> (-2.32%) ⬇️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@satween

satween commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Looks good to me, but we need to port it to into release branch of v2

Comment on lines +243 to +246
// If "_dd.rum.disable_jank_stats" is explicitly set to true, refrain from registering
// any frame state listeners; if false or not set, proceed normally
val disableJankStats = configuration.additionalConfig[DD_RUM_DISABLE_JANK_STATS_TAG]
val allowJankStats = disableJankStats as? Boolean != true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

RumConfiguration.additionalConfig is something legacy I would say.

I would propose to add the explicit field to RumConfiguration and expose it through internal method which can be called via _RumInternalProxy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, that makes sense. I've switched to the approach you suggest.

@awforsythe
awforsythe requested a review from 0xnm November 12, 2025 14:23
* Disables JankStats tracking. This flag may be enabled by cross-platform SDKs where
* native frame metrics are not meaningful.
*/
internal fun setDisableJankStats(disable: Boolean): Builder {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor: it can be just disableJankStats, but let's keep it like that, it is only for us anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

btw, probably PR title should be updated, since approach is different now

@awforsythe awforsythe changed the title fix: Allow JankStats to be explicitly disabled via additionalConfig fix: Add internal disableJankStats config option Nov 12, 2025
@awforsythe
awforsythe merged commit 795feec into develop Nov 12, 2025
26 checks passed
@awforsythe
awforsythe deleted the aforsythe/RUM-12763/disable-jank-stats branch November 12, 2025 15:08
awforsythe added a commit to DataDog/dd-sdk-unity that referenced this pull request Nov 13, 2025
refs: RUM-12764

This PR updates Android RUM initialization logic such that we always set
`_dd.rum.disable_jank_stats` to `true` when configuring `dd-sdk-android`.

This change depends on [an accompanying dd-sdk-android fix](DataDog/dd-sdk-android#3000),
which will need to be released in v2. We'll need to bump the Unity SDK's
dd-sdk-android dependency once that release is available.
@ncreated
ncreated restored the aforsythe/RUM-12763/disable-jank-stats branch April 9, 2026 10:19
@0xnm
0xnm deleted the aforsythe/RUM-12763/disable-jank-stats branch April 24, 2026 09:43
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.

4 participants