Add trunk flag for adding SF skipped frames into traces.
Bug: 273701290
Test: FrameTimelineTest#traceDisplayFrameSkipped, play with perfetto
Change-Id: Ib5f884a14dc6526e2a2b5a1371be7715a20cd0a9
diff --git a/services/surfaceflinger/FrameTimeline/Android.bp b/services/surfaceflinger/FrameTimeline/Android.bp
index 2d4ec04..29c9432 100644
--- a/services/surfaceflinger/FrameTimeline/Android.bp
+++ b/services/surfaceflinger/FrameTimeline/Android.bp
@@ -28,6 +28,7 @@
],
static_libs: [
"libperfetto_client_experimental",
+ "libsurfaceflinger_common",
],
export_include_dirs: ["."],
}
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index dfbb55d..9dc3938 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -21,6 +21,7 @@
#include "FrameTimeline.h"
#include <android-base/stringprintf.h>
+#include <common/FlagManager.h>
#include <utils/Log.h>
#include <utils/Trace.h>
@@ -1200,7 +1201,9 @@
surfaceFrame->trace(mToken, monoBootOffset);
}
- addSkippedFrame(surfaceFlingerPid, monoBootOffset, previousActualPresentTime);
+ if (FlagManager::getInstance().add_sf_skipped_frames_to_trace()) {
+ addSkippedFrame(surfaceFlingerPid, monoBootOffset, previousActualPresentTime);
+ }
}
float FrameTimeline::computeFps(const std::unordered_set<int32_t>& layerIds) {
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index 8da7d8e..e2a1498 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -120,6 +120,7 @@
DUMP_READ_ONLY_FLAG(hotplug2);
DUMP_READ_ONLY_FLAG(hdcp_level_hal);
DUMP_READ_ONLY_FLAG(multithreaded_present);
+ DUMP_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace);
#undef DUMP_READ_ONLY_FLAG
#undef DUMP_SERVER_FLAG
@@ -188,6 +189,7 @@
FLAG_MANAGER_READ_ONLY_FLAG(hotplug2, "")
FLAG_MANAGER_READ_ONLY_FLAG(hdcp_level_hal, "")
FLAG_MANAGER_READ_ONLY_FLAG(multithreaded_present, "debug.sf.multithreaded_present")
+FLAG_MANAGER_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace, "")
/// Trunk stable server flags ///
FLAG_MANAGER_SERVER_FLAG(late_boot_misc2, "")
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index e3e4f80..9aabbb9 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -59,6 +59,7 @@
bool hotplug2() const;
bool hdcp_level_hal() const;
bool multithreaded_present() const;
+ bool add_sf_skipped_frames_to_trace() const;
protected:
// overridden for unit tests
diff --git a/services/surfaceflinger/surfaceflinger_flags.aconfig b/services/surfaceflinger/surfaceflinger_flags.aconfig
index bb3c94a..71c59b2 100644
--- a/services/surfaceflinger/surfaceflinger_flags.aconfig
+++ b/services/surfaceflinger/surfaceflinger_flags.aconfig
@@ -71,6 +71,14 @@
}
flag {
+ name: "add_sf_skipped_frames_to_trace"
+ namespace: "core_graphics"
+ description: "Add SurfaceFlinger dropped Frames to frame timeline"
+ bug: "273701290"
+ is_fixed_read_only: true
+}
+
+flag {
name: "refresh_rate_overlay_on_external_display"
namespace: "core_graphics"
description: "enable refresh rate indicator on the external display"
diff --git a/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp b/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
index e040028..6d87717 100644
--- a/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
+++ b/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "FlagUtils.h"
+#include "com_android_graphics_surfaceflinger_flags.h"
#include "gmock/gmock-spec-builders.h"
#include "mock/MockTimeStats.h"
#undef LOG_TAG
@@ -1059,6 +1061,9 @@
}
TEST_F(FrameTimelineTest, traceDisplayFrameSkipped) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::add_sf_skipped_frames_to_trace,
+ true);
+
// setup 2 display frames
// DF 1: [22,40] -> [5, 40]
// DF : [36, 70] (Skipped one, added by the trace)