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 new file mode 100644 index 00000000..b6278306 --- /dev/null +++ b/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md @@ -0,0 +1,104 @@ +# Studio Performance Optimization - Face Group Thumbnails + +## Problem + +Loading face groups for large files (e.g., Charade with 153 groups, 2,451 traces) is slow because: +1. All thumbnails load immediately on page render +2. Thumbnail concurrency is limited to 16 parallel requests +3. Each thumbnail requires a separate HTTP request + ffmpeg extraction (~0.5-1s each) + +**Estimated load time before: ~76 seconds** + +## Changes Required + +### 1. Increase Thumbnail Concurrency + +**File:** `src/store.ts` + +```typescript +// Line ~327: Change from 16 to 32 +const MAX_CONCURRENT = 32 // was 16 +``` + +**Effect:** Doubles parallel thumbnail loading capacity. + +--- + +### 2. Add Lazy Loading to Face Groups + +**File:** `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) + +**Before:** +```vue +
+``` + +**After:** +```vue +
+``` + +#### 2b. Merge Target Modal (~line 303) + +**Before:** +```vue +
+``` + +**After:** +```vue +
+``` + +#### 2c. Merge Candidate Modal (~line 273) + +**Before:** +```vue +
+``` + +**After:** +```vue +
+``` + +--- + +## How `v-observe` Works + +The directive is already defined in `src/directives/vObserve.ts`: +- Uses `IntersectionObserver` with `rootMargin: '200px 0px'` +- Only triggers when element enters viewport (+200px buffer) +- Auto-disconnects after first trigger +- Falls back to immediate load if element is already visible + +--- + +## Expected Results + +| Metric | Before | After | +|--------|--------|-------| +| Concurrent loads | 16 | **32** | +| Initial thumbnails | All 153 | **Only visible (~6-10)** | +| Charade load time | ~76s | **<2s** (first screen) | + +--- + +## Testing + +1. Open Charade file in PeopleView +2. Verify face group thumbnails load as you scroll down +3. Verify merge dialogs also lazy-load thumbnails +4. Check browser Network tab — thumbnails should not all fire at once + +--- + +## Notes + +- `loadTraceThumb` and `faceThumbsCache` are already imported in PeopleView.vue +- The `v-observe` directive is already registered globally in `src/main.ts` +- No new dependencies required