diff --git a/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md b/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md index b6278306..97a72820 100644 --- a/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md +++ b/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md @@ -9,11 +9,60 @@ Loading face groups for large files (e.g., Charade with 153 groups, 2,451 traces **Estimated load time before: ~76 seconds** -## Changes Required +--- + +## Core API Changes (Already Deployed) + +These changes are already on the Core side. Studio just needs to use the new endpoints. + +### A. Thumbnail API Now Uses Pre-Cached key_face.jpg + +**Endpoint:** `GET /api/v1/face-thumbnail?uuid={uuid}&trace_id={tid}&frame={frame}` + +The API now checks `output/{uuid}/trace_{tid}/key_face.jpg` before falling back to ffmpeg. + +| Scenario | Before | After | +|----------|--------|-------| +| First request | ~500ms (ffmpeg) | **~8ms** (read file) | +| All traces have key_face.jpg | Yes | ✅ Used automatically | + +**Studio action:** No code change needed. Just pass `trace_id` in the thumbnail request. + +### B. Face-Groups API Supports Payload Reduction + +**Endpoint:** `GET /api/v1/file/{uuid}/face-groups?include_trace_ids=false` + +| Param | Payload Size | Response | +|-------|-------------|----------| +| Default (omit) | ~32KB (Charade) | Full data with `trace_ids` array | +| `include_trace_ids=false` | **~17KB** (-48%) | Groups without `trace_ids` | + +**Response when `include_trace_ids=false`:** +```json +{ + "face_groups": [ + { + "group_id": 1, + "name": "Person_5", + "trace_count": 248, + "representative_trace": 3725, + "editable": true + } + ] +} +``` + +Note: `trace_ids` field is **omitted** (not `null`, just not present). + +**Studio action:** Use `?include_trace_ids=false` for initial load. Fetch full data only when user clicks into a group. + +--- + +## Studio Changes Required ### 1. Increase Thumbnail Concurrency -**File:** `src/store.ts` +**File:** `/Users/accusys/momentry_studio/src/store.ts` ```typescript // Line ~327: Change from 16 to 32 @@ -24,13 +73,40 @@ const MAX_CONCURRENT = 32 // was 16 --- -### 2. Add Lazy Loading to Face Groups +### 2. Use Reduced Payload for Initial Load -**File:** `src/views/PeopleView.vue` +**File:** `/Users/accusys/momentry_studio/src/api/index.ts` (or wherever face-groups is fetched) + +**Before:** +```typescript +const resp = await apiCall('get_face_groups', { fileUuid: uuid }) +``` + +**After:** +```typescript +// Initial load: lightweight, no trace_ids +const resp = await fetch(`/api/v1/file/${uuid}/face-groups?include_trace_ids=false`, { + headers: { 'Authorization': `Bearer ${apiKey}` } +}) +``` + +When user clicks into a group to see members, fetch full data: +```typescript +const resp = await fetch(`/api/v1/file/${uuid}/face-groups`, { + headers: { 'Authorization': `Bearer ${apiKey}` } +}) +// Or fetch single group's traces if you add a per-group endpoint later +``` + +--- + +### 3. Add Lazy Loading to Face Groups + +**File:** `/Users/accusys/momentry_studio/src/views/PeopleView.vue` The `v-observe` directive (IntersectionObserver) is already used for unassigned traces. Apply the same pattern to face groups. -#### 2a. Main Face Groups Section (~line 53) +#### 3a. Main Face Groups Section (~line 53) **Before:** ```vue @@ -42,7 +118,7 @@ The `v-observe` directive (IntersectionObserver) is already used for unassigned