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

Unified Diff: tools/telemetry/telemetry/core/platform/android_platform_backend.py

Issue 776883004: Basic android app implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More review comments. Created 6 years 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
Index: tools/telemetry/telemetry/core/platform/android_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
index 3e058503fe8d1e415970e39a765ff5d80475fc61..16c0d89327b013d6b87fc7e8928cffe84a735aa0 100644
--- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
@@ -44,6 +44,11 @@ try:
except Exception:
surface_stats_collector = None
+try:
+ import psutil # pylint: disable=import-error
+except ImportError:
+ psutil = None
+
class AndroidPlatformBackend(
linux_based_platform_backend.LinuxBasedPlatformBackend):
@@ -85,6 +90,8 @@ class AndroidPlatformBackend(
self._device_cert_util = None
self._is_test_ca_installed = False
+ _FixPossibleAdbInstability()
+
@classmethod
def SupportsDevice(cls, device):
return isinstance(device, android_device.AndroidDevice)
@@ -592,3 +599,25 @@ class AndroidPlatformBackend(
self._adb.device_serial()],
stdout=subprocess.PIPE).communicate()[0])
return ret
+
+
+def _FixPossibleAdbInstability():
+ """Host side workaround for crbug.com/268450 (adb instability).
+
+ The adb server has a race which is mitigated by binding to a single core.
+ """
+ if not psutil:
+ return
+ for process in psutil.process_iter():
+ try:
+ if 'adb' in process.name:
+ if 'cpu_affinity' in dir(process):
+ process.cpu_affinity([0]) # New versions of psutil.
+ elif 'set_cpu_affinity' in dir(process):
+ process.set_cpu_affinity([0]) # Older versions.
+ else:
+ logging.warn(
+ 'Cannot set CPU affinity due to stale psutil version: %s',
+ '.'.join(str(x) for x in psutil.version_info))
+ except (psutil.NoSuchProcess, psutil.AccessDenied):
+ logging.warn('Failed to set adb process CPU affinity')

Powered by Google App Engine
This is Rietveld 408576698