Status Update
Comments
cc...@google.com <cc...@google.com> #2
We haven't attempted to support Unity / SurfaceView with startActivityAndWait(), or StartupTimingMetric.
What would you like here? Just an option to skip the framestats dump for native activities?
If we did that, we may not block long enough to know if the first frame has drawn, so I'd be inclined to call it startActivityNonBlocking()
or similar.
We could potentially look at dumpsys surfaceflinger
to see window information to see if first frame has posted, but I'm not sure if the first frame is significant at all. It's often a useful signal in an Android View/Compose app because the UI blocks until content is set (and potentially until it's ready with the pattern used by a Splash Screen)
ys...@google.com <ys...@google.com> #3
I think I effectively wrote a possibly incorrect startActivityNonBlocking() to work around this.
private fun MacrobenchmarkScope.startActivity() {
val intent = Intent(Intent.ACTION_MAIN).apply {
component = ComponentName(PACKAGE_NAME, "com.unity3d.player.UnityPlayerActivity")
flags = FLAG_ACTIVITY_NEW_TASK
}
InstrumentationRegistry.getInstrumentation().context.startActivity(intent)
}
So having that would be helpful.
Also the StartupTimingMetric fails in this case, so I added another one to allow it to proceed.
class EmptyMetric: TraceMetric() {
override fun getResult(
captureInfo: CaptureInfo,
traceSession: PerfettoTraceProcessor.Session
): List<Measurement> {
return listOf(Measurement("empty", 0.0))
}
}
So it would be good to know how to capture this timing also.
ys...@google.com <ys...@google.com> #4
FrameTimingMetric also fails, I wonder if there are good suggestions for metrics in the game world?
ys...@google.com <ys...@google.com> #5
I tried FrameTimingGfxInfoMetric also, but similarly fails.
cc...@google.com <cc...@google.com> #6
All the FrameTimingMetric, StartupTimingMetric and friends won't work unless frames are produced by Views/Compose, with hardware acceleration enabled, as they look for specific toolkit emitted frame sections, like choreographer and renderthread tracepoints.
They would have to be rewritten entirely to understand the frame structure of any other rendering system, especially game engines, and it would only be straightforward if the game engine emits relevant data into perfetto, as we haven't opened general APIs for getting data from shell commands.
ys...@google.com <ys...@google.com> #7
Could we have a Metric.Disabled sentinel that doesn't collect metrics, but still allows the macrobenchmark to run to completion?
cc...@google.com <cc...@google.com> #8
Yes, that's reasonable
In the meantime, you can add your own custom TraceMetric which just returns one constant measurement:
class IgnoredMetric : TraceMetric() {
override fun getResult(
captureInfo: CaptureInfo,
traceSession: PerfettoTraceProcessor.Session
): List<Measurement> {
return listOf(Measurement("ignored", 0))
}
}
ys...@google.com <ys...@google.com> #9
Yep, that's what I have in EmptyMetric
. I guess it would be nice if it didn't bother showing the zeros :)
I'm not blocked.
Description
Component used: Macrobenchmark Version used: 1.2.3 Devices/Android versions reproduced on: API 33
I can share a private repo.
App is a Unity app, which has UnityPlayerActivity which basically includes a SurfaceView.