[SurfaceFlinger] Push atoms on janky events
For now define a jank event as a window of 100ms containing at least one
missed frame. On the server-side we can then configure whether tracing
is triggered based on the number of missed frames in a window.
A 100ms window should be safe, as always-on tracing should contain ~10
seconds of trace data
Further details on when we report a jank:
* We don't report a jank if it occurred more than a second in the past,
since we need a good guarantee that the trace will actually contain the
jank
* We don't report a jank if the display is off or in doze, as missed
frames in those power modes are either not actionable or not
user-perceived.
* We only report a jank on userdebug or eng builds. This will never be
enabled on user builds, so there's no reason to incur the cost of
pushing the atom on those builds.
Bug: 148543048
Test: builds
Test: statsd_testdrive 257
Change-Id: Ifc544d544ef8da9adec944507fe71dc5550c13e8
(cherry picked from commit 5f487d4e17ff7347e927f5e5b0a2a97c84ad16c7)
Merged-In: Ifc544d544ef8da9adec944507fe71dc5550c13e8
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index c79621b..e4a5da1 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -982,6 +982,7 @@
// constant members (no synchronization needed for access)
const nsecs_t mBootTime = systemTime();
bool mGpuToCpuSupported = false;
+ bool mIsUserBuild = true;
// Can only accessed from the main thread, these members
// don't need synchronization
@@ -1225,6 +1226,11 @@
// Flags to capture the state of Vsync in HWC
HWC2::Vsync mHWCVsyncState = HWC2::Vsync::Disable;
HWC2::Vsync mHWCVsyncPendingState = HWC2::Vsync::Disable;
+
+ // Fields tracking the current jank event: when it started and how many
+ // janky frames there are.
+ nsecs_t mMissedFrameJankStart = 0;
+ int32_t mMissedFrameJankCount = 0;
};
} // namespace android