ui: fix async and global slice tracks

This CL fixes tow issues:
* global slice tracks were missing a "group by track_id" leading to
  either a null track showing up (if there were no global tracks) or
  only showing a single slice track (even if there was more than one).
* async proces tracks were not qualifying which table they were getting
  the column from - now that multiple tables contain "id", this was
  causing a clash and causing these tracks to not be added.

Bug: 148133325
Change-Id: Id0ac10de0bde7c613214c3af72b63b8235e74bbf
diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts
index d7b07b6..c5b6130 100644
--- a/ui/src/controller/trace_controller.ts
+++ b/ui/src/controller/trace_controller.ts
@@ -374,10 +374,14 @@
 
     const upidToProcessTracks = new Map();
     const rawProcessTracks = await engine.query(`
-      select id, upid, process_track.name, max(depth) as maxDepth
+      select
+        process_track.id as track_id,
+        process_track.upid,
+        process_track.name,
+        max(slice.depth) as max_depth
       from process_track
-      inner join slice on slice.track_id = process_track.id
-      group by track_id
+      join slice on slice.track_id = process_track.id
+      group by process_track.id
     `);
     for (let i = 0; i < rawProcessTracks.numRecords; i++) {
       const trackId = rawProcessTracks.columns[0].longValues![i];
@@ -473,8 +477,10 @@
         track.name as track_name,
         track.id as track_id,
         max(depth) as max_depth
-      from track join slice on track.id = slice.track_id
+      from track
+      join slice on track.id = slice.track_id
       where track.type = 'track'
+      group by track_id
     `);
 
     for (let i = 0; i < globalSliceTracks.numRecords; i++) {