Fixed
Status Update
Comments
py...@gmail.com <py...@gmail.com> #2
Interestingly this used to be implemented with sendMessageAtFrontOfQueue()
:
The behavior changes in this commit:
I'm not seeing anything in the commit message or comments related to the change in posting behavior.
ch...@google.com <ch...@google.com> #3
Good catch. I don't see (or recall) why that CL triggered that change, other than it was refactoring related code to handle multiple listeners and maybe my fingers just input the wrong version of that function...
Checking on the logic here, but seems like the fix is just to do what it used to do.
Checking on the logic here, but seems like the fix is just to do what it used to do.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 4cf7234683223e57698944601bc7bb6092daa34b
Author: Chet Haase <chet@google.com>
Date: Fri Jul 08 09:15:37 2022
Send preDraw message at front of queue pre API 24
Prior to API level 24, JankStats uses an OnPreDrawListener to track frame
times. The handler for posting these messages originally posted them at the
front of the queue. This CL returns to that logic.
Bug: 233358407
Test: JankStatsTest runs, manual testing
RelNote: "Return to original logic of posting OnPreDrawListener messages at
front of queue, for more consistent and predictable frame timing."
Change-Id: I05a434fe9453ea1be28d398e3eb284dd9b0cb64a
A metrics/integration-tests/janktest/src/main/res/layout/simple_layout.xml
M metrics/metrics-performance/src/main/java/androidx/metrics/performance/JankStatsApi16Impl.kt
M metrics/integration-tests/janktest/src/main/AndroidManifest.xml
A metrics/integration-tests/janktest/src/main/java/androidx/metrics/performance/janktest/SimpleLoggingActivity.kt
https://android-review.googlesource.com/2147364
Branch: androidx-main
commit 4cf7234683223e57698944601bc7bb6092daa34b
Author: Chet Haase <chet@google.com>
Date: Fri Jul 08 09:15:37 2022
Send preDraw message at front of queue pre API 24
Prior to API level 24, JankStats uses an OnPreDrawListener to track frame
times. The handler for posting these messages originally posted them at the
front of the queue. This CL returns to that logic.
Bug: 233358407
Test: JankStatsTest runs, manual testing
RelNote: "Return to original logic of posting OnPreDrawListener messages at
front of queue, for more consistent and predictable frame timing."
Change-Id: I05a434fe9453ea1be28d398e3eb284dd9b0cb64a
A metrics/integration-tests/janktest/src/main/res/layout/simple_layout.xml
M metrics/metrics-performance/src/main/java/androidx/metrics/performance/JankStatsApi16Impl.kt
M metrics/integration-tests/janktest/src/main/AndroidManifest.xml
A metrics/integration-tests/janktest/src/main/java/androidx/metrics/performance/janktest/SimpleLoggingActivity.kt
Description
androidx.metrics
module used: metrics-performanceandroidx.metrics
version used: 1.0.0-alpha01I was reading the sources for
androidx.metrics.performance.DelegatingOnPreDrawListener#onPreDraw
and noticed what seems like a potential bug pre API 24 (or at list a limitation):androidx.metrics.performance.DelegatingOnPreDrawListener#onPreDraw
posts an async message (great) but not at the front.Pre API 24, the “end” time of a frame is approximated by posting an async message from onPreDraw.
This means there can be messages that were already posted and will execute before it runs. MessageQueue only looks for async messages when there’s a sync barrier, otherwise, they keep their posted order. So if there’s no sync barrier then any already enqueued message will execute right after the frame but before the message posted from onPreDraw runs, which means the frame end time will be off. If there is a sync barrier, this still applies if there are other async messages already posted.