Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tools: keep unavailable FrameTimeline metrics out of reports

SlivenRed30f34b993751
diff --git a/tests/test_trace_report.py b/tests/test_trace_report.py
index 8b2f3da79..83e1cbbf7 100644
--- a/tests/test_trace_report.py
+++ b/tests/test_trace_report.py
@@ -80,6 +80,21 @@ class StartMetricsTest(unittest.TestCase):
m = report.start_metrics(fake_trace(draws=[(1500, 8), (2600, 8)]), PKG)
self.assertEqual(m["frames"], 2)
+ def test_without_frame_timeline_keeps_start_metrics_but_not_missed_deadlines(self):
+ for other_app_frames in (False, True):
+ with self.subTest(other_app_frames=other_app_frames):
+ q = fake_trace(draws=[(1100, 8)])
+ if other_app_frames:
+ q("insert into actual_frame_timeline_slice values (1060000000, 16000000, 3, 'None')")
+ m = report.start_metrics(q, PKG)
+ self.assertEqual(m["first frame"], 65)
+ self.assertEqual(m["frames"], 2)
+ self.assertNotIn("missed", m)
+
+ def test_frame_timeline_can_measure_zero_missed_deadlines(self):
+ m = report.start_metrics(fake_trace(frames=[16, 16], missed=0), PKG)
+ self.assertEqual(m["missed"], 0)
+
def test_newest_launcher_process_is_used(self):
self.assertEqual(report.threads(fake_trace(), PKG), (2, 1, 2))
@@ -98,6 +113,26 @@ class NavMetricsTest(unittest.TestCase):
self.assertEqual(m["gpu median"], 3)
self.assertEqual(m["missed"], 2)
+ def test_without_frame_timeline_counts_draws_but_not_full_frame_times_or_deadlines(self):
+ for other_app_frames in (False, True):
+ with self.subTest(other_app_frames=other_app_frames):
+ q = fake_trace(draws=[(1100, 6), (1120, 8)], gpu=[(1101, 2), (1121, 4)])
+ if other_app_frames:
+ q("insert into actual_frame_timeline_slice values (1060000000, 16000000, 3, 'None')")
+ m = report.nav_metrics(q, PKG)
+ self.assertEqual(m["frames"], 3)
+ self.assertEqual(m["draw median"], 8)
+ self.assertEqual(m["gpu median"], 3)
+ self.assertNotIn("frame median", m)
+ self.assertNotIn("frame p90", m)
+ self.assertNotIn("missed", m)
+
+ def test_frame_timeline_can_measure_zero_missed_deadlines(self):
+ m = report.nav_metrics(fake_trace(frames=[16, 16], missed=0), PKG)
+ self.assertEqual(m["frames"], 2)
+ self.assertEqual(m["frame median"], 16)
+ self.assertEqual(m["missed"], 0)
+
class ReportTest(unittest.TestCase):
RUNS = [("home-1", {"first frame": 90, "onResume": 40}), ("home-2", {"first frame": 300, "onResume": 290}),
@@ -121,6 +156,16 @@ class ReportTest(unittest.TestCase):
text = report.report(self.RUNS, None, False, nav=False)
self.assertNotIn("bindApplication", text)
+ def test_unavailable_missed_deadlines_are_distinct_from_measured_zero(self):
+ for nav in (False, True):
+ with self.subTest(nav=nav):
+ measure = report.nav_metrics if nav else report.start_metrics
+ runs = [("without-timeline", measure(fake_trace(), PKG)),
+ ("with-timeline", measure(fake_trace(frames=[16], missed=0), PKG))]
+ text = report.report(runs, None, True, nav=nav)
+ missed = next(row for row in text.splitlines() if row.startswith("| frames that missed"))
+ self.assertEqual(missed.split(" | ")[1:], ["–", "0", "0", "0–0 |"])
+
class FilesTest(unittest.TestCase):
def test_folders_expand_in_run_order(self):
diff --git a/tools/trace.md b/tools/trace.md
index 8720735b9..c2f6ab503 100644
--- a/tools/trace.md
+++ b/tools/trace.md
@@ -44,6 +44,11 @@ tools/venv/bin/python tools/trace_report.py traces/before --vs traces/after --ma
With `--vs`, a third table shows the change in each median. A run over twice the median is starred.
+Frame times and missed deadlines need [FrameTimeline](https://perfetto.dev/docs/data-sources/frametimeline),
+available on Android 12 and later. Without its data for the launcher process, these metrics are omitted
+(or shown as `–` beside measured runs). `nav` still counts RenderThread draws and reports their duration
+and GPU waits where available; a draw's duration is not the full frame time.
+
## Rules
- **Repeat runs.** Record 5 runs per build, on the same TV with the same config, theme and wallpaper.
diff --git a/tools/trace_report.py b/tools/trace_report.py
index b0a2c1f47..fbe8022e6 100644
--- a/tools/trace_report.py
+++ b/tools/trace_report.py
@@ -95,9 +95,10 @@ def start_metrics(q, package):
out["frames"] = one(q, f"select count(*) from slice s join thread_track tt on s.track_id = tt.id "
f"where tt.utid = {render} and s.name like 'DrawFrame%' "
f"and s.ts >= {anchor} and s.ts < {anchor + WINDOW_NS}", 0)
- out["missed"] = one(q, f"select count(*) from actual_frame_timeline_slice where upid = {upid} "
- f"and jank_type like '%App Deadline Missed%' "
- f"and ts >= {anchor} and ts < {anchor + WINDOW_NS}", 0)
+ if one(q, f"select 1 from actual_frame_timeline_slice where upid = {upid} limit 1"):
+ out["missed"] = one(q, f"select count(*) from actual_frame_timeline_slice where upid = {upid} "
+ f"and jank_type like '%App Deadline Missed%' "
+ f"and ts >= {anchor} and ts < {anchor + WINDOW_NS}", 0)
return out
@@ -107,12 +108,15 @@ def nav_metrics(q, package):
if upid is None:
return {}
frames = sorted(r["dur"] / MS for r in q(f"select dur from actual_frame_timeline_slice where upid = {upid}"))
- out = {"frames": len(frames)}
+ out = {}
if frames:
+ out["frames"] = len(frames)
out["frame median"] = statistics.median(frames)
out["frame p90"] = frames[min(len(frames) - 1, int(0.9 * len(frames)))]
if render is not None:
draws = [r["dur"] / MS for r in q(slices(render, "s.name like 'DrawFrame%'", "s.dur"))]
+ if not frames:
+ out["frames"] = len(draws)
if draws:
out["draw median"] = statistics.median(draws)
waits = [r["dur"] / MS for r in q(f"select s.dur from slice s join thread_track tt on s.track_id = tt.id "
@@ -120,8 +124,9 @@ def nav_metrics(q, package):
f"and s.name like 'waiting for GPU completion%'")]
if waits:
out["gpu median"] = statistics.median(waits)
- out["missed"] = one(q, f"select count(*) from actual_frame_timeline_slice where upid = {upid} "
- f"and jank_type like '%App Deadline Missed%'", 0)
+ if frames:
+ out["missed"] = one(q, f"select count(*) from actual_frame_timeline_slice where upid = {upid} "
+ f"and jank_type like '%App Deadline Missed%'", 0)
return out