Merge "ui: Fix opening debug track on second trace"
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index 0bd01d4..c173c1c 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -1579,9 +1579,9 @@
     // falls back to the best-available alternative.
     //
     // Introduced in Android S.
-    // Deprecated and has no effect in Android T+ as using a suspend aware
-    // clock is the default behaviour.
-    optional bool prefer_suspend_clock_for_snapshot = 7 [deprecated = true];
+    // TODO(lalitm): deprecate this in T and make this the default if nothing
+    // crashes in S.
+    optional bool prefer_suspend_clock_for_snapshot = 7;
   }
   optional BuiltinDataSource builtin_data_sources = 20;
 
diff --git a/protos/perfetto/config/trace_config.proto b/protos/perfetto/config/trace_config.proto
index 5cb450d..dbc1bab 100644
--- a/protos/perfetto/config/trace_config.proto
+++ b/protos/perfetto/config/trace_config.proto
@@ -115,9 +115,9 @@
     // falls back to the best-available alternative.
     //
     // Introduced in Android S.
-    // Deprecated and has no effect in Android T+ as using a suspend aware
-    // clock is the default behaviour.
-    optional bool prefer_suspend_clock_for_snapshot = 7 [deprecated = true];
+    // TODO(lalitm): deprecate this in T and make this the default if nothing
+    // crashes in S.
+    optional bool prefer_suspend_clock_for_snapshot = 7;
   }
   optional BuiltinDataSource builtin_data_sources = 20;
 
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 9a15506..e8c019e 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -1579,9 +1579,9 @@
     // falls back to the best-available alternative.
     //
     // Introduced in Android S.
-    // Deprecated and has no effect in Android T+ as using a suspend aware
-    // clock is the default behaviour.
-    optional bool prefer_suspend_clock_for_snapshot = 7 [deprecated = true];
+    // TODO(lalitm): deprecate this in T and make this the default if nothing
+    // crashes in S.
+    optional bool prefer_suspend_clock_for_snapshot = 7;
   }
   optional BuiltinDataSource builtin_data_sources = 20;
 
diff --git a/src/tracing/core/tracing_service_impl.cc b/src/tracing/core/tracing_service_impl.cc
index 9a1f142..9ca22d8 100644
--- a/src/tracing/core/tracing_service_impl.cc
+++ b/src/tracing/core/tracing_service_impl.cc
@@ -1106,7 +1106,9 @@
   //      events.
   base::PeriodicTask::Args snapshot_task_args;
   snapshot_task_args.start_first_task_immediately = true;
-  snapshot_task_args.use_suspend_aware_timer = true;
+  snapshot_task_args.use_suspend_aware_timer =
+      tracing_session->config.builtin_data_sources()
+          .prefer_suspend_clock_for_snapshot();
   snapshot_task_args.task = [weak_this, tsid] {
     if (weak_this)
       weak_this->PeriodicSnapshotTask(tsid);
diff --git a/ui/src/controller/adb.ts b/ui/src/controller/adb.ts
index 5c1cdbb..42d8138 100644
--- a/ui/src/controller/adb.ts
+++ b/ui/src/controller/adb.ts
@@ -293,7 +293,7 @@
         stream.onClose = () => {};
         resolve(stream);
       };
-      stream.onClose = () => reject();
+      stream.onClose = () => reject(`Failed to openStream svc=${svc}`);
     });
   }