Metrics
Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |
---|---|---|---|---|
January 10, 2024 | - | - | 1.0.0-beta01 | - |
Declaring dependencies
To add a dependency on Metrics, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for
your app or module:
Groovy
dependencies { implementation "androidx.metrics:metrics-performance:1.0.0-beta01" }
Kotlin
dependencies { implementation("androidx.metrics:metrics-performance:1.0.0-beta01") }
For more information about dependencies, see Add build dependencies.
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 1.0.0
Version 1.0.0-beta01
January 10, 2024
The API and functionality of this library has been stable for some time. This release simply pushes the library to beta.
androidx.metrics:metrics-performance:1.0.0-beta01
is released. Version 1.0.0-beta01 contains these commits.
Version 1.0.0-alpha04
April 5, 2023
This release updates JankStats to the latest fixes, which include more accurate and comprehensive timing information.
androidx.metrics:metrics-performance:1.0.0-alpha04
is released. Version 1.0.0-alpha04 contains these commits.
API Changes
cpuDuration
now more accurate, also newtotalDuration
on API31 (I59ce8, b/243694893)
Version 1.0.0-alpha03
July 27, 2022
androidx.metrics:metrics-performance:1.0.0-alpha03
is released. Version 1.0.0-alpha03 contains these commits.
This release contains minor API refinements as the library gets closer to beta. One of the API changes removes the Executor from the
createAndTrack()
factory method for creating aJankStats
object. This has implications for theOnFrameListener
callback, as that listener is now called on the thread which delivers the per-frame data toJankStats
(the Main/UI thread on versions earlier than API 24, and theFrameMetrics
thread on API 24+). Moreover, theFrameData
object passed to the listener is now reused every frame, so data from that object must be copied and cached elsewhere during the callback, as that object should be considered obsolete as soon as the listener returns.There were also various bug fixes, including some concurrency issues.
Finally, the fix to reuse
FrameData
(mentioned above) means that there are now zero allocations per frame due to frame metrics delivery. There weren’t many allocations before, but the new approach means that you can useJankStats
without incurring any per-frame GC overhead in your app.
API Changes
- Updated method and parameter names in
PerformanceMetricsState
to make the results of those calls clearer. (I56da5, b/233421985) - Added benchmark tests to track allocations, eliminated some internal allocations related to state management and reporting. Note that
FrameData
passed to listeners is now considered volatile; that structure will be reused for the next frame and the data is only reliable until the listener returns. - Removed Executor from constructor for
JankStats
; listeners are now called on whatever thread the internal data was received upon. (I12743)
Bug Fixes
- Fixed crash due to double-removal of
OnFrameMetricsAvailableListener
(I44094, b/239457413) - Return to original logic of posting
OnPreDrawListener
messages at front of queue, for more consistent and predictable frame timing. (I05a43, b/233358407) - Fixed
ConcurrentModificationException
bug where the list of listener delegates was being modified while it was also being iterated through to send per-frame data. (Ib7693, b/236612357)
Version 1.0.0-alpha02
June 29, 2022
androidx.metrics:metrics-performance:1.0.0-alpha02
is released. Version 1.0.0-alpha02 contains these commits.
API Changes
- Renamed
MetricsStateHolder
to just Holder (withinPerformanceMetricsState
): (I5a4d9, b/226565716, b/213499234)
Bug Fixes
- Fixed timing issue where states could be replaced with new values before the frames had been processed where the old state would have been correct (aosp/2061892, b/213499234)
- Fixed concurrent modification exception in adding/removing listeners (aosp/2092714, b/213499234)
- Made startTime calculations more accurate (aosp/2027704, b/213245198)
- Fixed bug in
FrameData.equals()
implementation (aosp/2025866, b/218296544)
Version 1.0.0-alpha01
February 9, 2022
androidx.metrics:metrics-performance:1.0.0-alpha01
is released. Version 1.0.0-alpha01 contains these commits.
New Features
- The
JankStats
library provides functionality to instrument and receive callbacks in your application at runtime which can help find real world performance problems. JankStats
combines an API that makes it easy to inject information about UI state with capabilities for tracking and reporting per-frame performance to allow developers to understand not whether an application has performance issues, but when and why.