     slice.name,
     slice.ts,
     slice.dur,
-    slice.ts + slice.dur AS ts_end
-  FROM slice
-  JOIN android_sysui_cuj_sf_main_thread_track main_track ON slice.track_id = main_track.id
+    slice.ts + slice.dur AS ts_end,
+    gcs.gcs_idx
+  FROM slice
+  JOIN android_sysui_cuj_sf_main_thread_track main_track ON slice.track_id = main_track.id
+  LEFT JOIN android_sysui_cuj_sf_mts_to_gcs gcs ON slice.ts = gcs.ts
   WHERE slice.dur > 0 AND slice.name GLOB 'composite*';
 
 DROP VIEW IF EXISTS android_sysui_cuj_surfaceflinger_commit_composite_frames_in_cuj;

JOIN android_sysui_cuj_sf_vsync_boundaries cuj_boundaries
WHERE vsync >= cuj_boundaries.vsync_min AND vsync <= cuj_boundaries.vsync_max;

-- Find just the onMessageInvalidate slices, within the CUJ (by vsync)
DROP VIEW IF EXISTS android_sysui_cuj_surfaceflinger_on_message_invalidate_slices_in_cuj;
CREATE VIEW android_sysui_cuj_surfaceflinger_on_message_invalidate_slices_in_cuj AS

  JOIN android_sysui_cuj_sf_ts_boundaries cuj_boundaries
  ON slice.ts >= cuj_boundaries.ts AND slice.ts <= cuj_boundaries.ts_end
  WHERE slice.dur > 0;

-- Those SurfaceFlinger Frames where we missed the deadline
-- To avoid overlap - which could result in counting janky slices more than once - we limit the
