Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1260)

Unified Diff: build/android/pylib/surface_stats_collector.py

Issue 12320097: Android / Telemetry: fixes surface stats collector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/scrolling_action.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/surface_stats_collector.py
diff --git a/build/android/pylib/surface_stats_collector.py b/build/android/pylib/surface_stats_collector.py
index 9c0cb7e32c6c1adcca8047685cee040fb1d43721..cf5a280c894608e3c4a0eebaa9591c7008da0ba9 100644
--- a/build/android/pylib/surface_stats_collector.py
+++ b/build/android/pylib/surface_stats_collector.py
@@ -96,12 +96,29 @@ class SurfaceStatsCollector(object):
last_timestamp = 0
first_timestamp = 0
latencies = []
+ retries = 0
+ has_collected_data = False
while not self._stop_event.is_set():
self._get_data_event.wait(1)
try:
(t, last_timestamp) = self._GetSurfaceFlingerLatencyData(last_timestamp,
latencies)
+ if (t, last_timestamp) == (None, None):
+ retries += 1
+ if retries < 3:
+ continue
+ if has_collected_data:
+ # Some data has already been collected, but either the app
+ # was closed or there's no new data. Signal the main thread and
+ # wait.
+ self._data_queue.put((None, None))
+ self._stop_event.wait()
+ break
+ raise Exception('Unable to get surface flinger latency data')
+
+ has_collected_data = True
+
if not first_timestamp:
first_timestamp = t
@@ -151,10 +168,8 @@ class SurfaceStatsCollector(object):
A tuple containing:
- The timestamp of the beginning of the first frame (ns),
- The timestamp of the end of the last frame (ns).
-
- Raises:
- Exception if failed to run the SurfaceFlinger command or SurfaceFlinger
- returned invalid result.
+ The tuple may be (None, None) if there was no data collected (for example,
+ if the app was closed before the collector thread has finished).
"""
# adb shell dumpsys SurfaceFlinger --latency <window name>
# prints some information about the last 128 frames displayed in
@@ -184,7 +199,8 @@ class SurfaceStatsCollector(object):
results = self._adb.RunShellCommand(
'dumpsys SurfaceFlinger --latency %s/%s' %
(self._window_package, self._window_activity), log_result=True)
- assert len(results)
+ if not len(results):
+ return (None, None)
refresh_period = int(results[0])
last_timestamp = previous_timestamp
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/scrolling_action.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698