RUMM-3216 use jank stats#1405
Conversation
0xnm
left a comment
There was a problem hiding this comment.
nice solution! I've added few comments to clarify.
| @Suppress( | ||
| "UnsafeThirdPartyFu" + | ||
| "nctionCall" | ||
| ) // pool size can't be <= 0 |
| // region JankStats.OnFrameListener | ||
|
|
||
| override fun onFrame(volatileFrameData: FrameData) { | ||
| println("$volatileFrameData") |
| kotlin = "1.8.10" | ||
| kotlinSP = "1.8.10-1.0.9" |
There was a problem hiding this comment.
do we need it as a part of this PR? I would rather handle it in the SDK v2 branch with Gradle 8 update (which is based on Kotlin 1.8 as well, so that we don't have conflicts for the build classpath), and also checking API/ABI compatibility.
There was a problem hiding this comment.
Unfortunately I need to use this version otherwise there's an incompatibility with the Metrics library.
There was a problem hiding this comment.
ok, we still have the following anyway in the Kotlin compiler configuration:
apiVersion = "1.6"
languageVersion = "1.6"
So shouldn't be any difference on the client side apart of the dependency resolution. It can be though the issue on the client side that Kotlin is resolved to 1.8 and thus produces bytecode not compatible with something else (like React Native), but at least from the SDK integration point should be good.
| import androidx.lifecycle.ViewModelProviders | ||
| import androidx.navigation.NavController | ||
| import androidx.navigation.fragment.NavHostFragment.findNavController | ||
| import androidx.navigation.fragment.NavHostFragment.Companion.findNavController |
There was a problem hiding this comment.
Why do we need to specify Companion now? Is it related to the Kotlin 1.8 change?
There was a problem hiding this comment.
Yes, it's changed because of Kotlin 1.8
|
|
||
| override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { | ||
| try { | ||
| JankStats.createAndTrack(activity.window, this) |
There was a problem hiding this comment.
this will work only for activity windows but will not measure the frame rate for DialogWindow or PopUpWindow. I guess once we add that ticket to support that in RUM we will have to find a different way to plugin in the JankStats into those windows too.
+ upgrade kotlin related dependencies (needed to be compatible with the Metrics library)
82c1637 to
3ccb996
Compare
3ccb996 to
2ce0d84
Compare
0xnm
left a comment
There was a problem hiding this comment.
nice! I've left a comment wondering if we should change also the way we detect refresh rate.
| ) | ||
| } | ||
| jankStatsActivityLifecycleListener = JankStatsActivityLifecycleListener(frameRateVitalMonitor, internalLogger) | ||
| (appContext as? Application)?.registerActivityLifecycleCallbacks(jankStatsActivityLifecycleListener) |
There was a problem hiding this comment.
should we modify the way we are checking refresh rate? currently we are using RumViewScope#detectRefreshRateScale, which relies on the view key and the presence of activity/fragment there (which may be missing in case of manual instrumentation or calls coming from cross-platform).
But now, since we are listening for activities anyway, we can access UI context at any time and basically pass this info with a sample, making things work properly even for cross-platform.
wdyt?
There was a problem hiding this comment.
That makes a lot of sense indeed
|
|
||
| override fun onFrame(volatileFrameData: FrameData) { | ||
| val durationNs = volatileFrameData.frameDurationUiNanos | ||
| if (durationNs > 0.0) { |
There was a problem hiding this comment.
in which case it can be negative or zero?
Codecov Report
@@ Coverage Diff @@
## develop #1405 +/- ##
===========================================
+ Coverage 81.94% 82.09% +0.16%
===========================================
Files 363 363
Lines 13031 12974 -57
Branches 2191 2164 -27
===========================================
- Hits 10677 10651 -26
+ Misses 1688 1668 -20
+ Partials 666 655 -11
|
What does this PR do?
Use the JankStats library to get the actual frame durations.
Motivation
Using the Choreographer like we did forced a redraw of all frames, which was not necessary if the content didn't require it.
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)