diff --git a/OPTIMIZATION_TASKS.md b/OPTIMIZATION_TASKS.md new file mode 100644 index 00000000..b73b78a4 --- /dev/null +++ b/OPTIMIZATION_TASKS.md @@ -0,0 +1,50 @@ +# Optimization Task Stubs + +The following tasks were identified and implemented to resolve high CPU/GPU usage and potential crashes on the website. + +## Completed Tasks + +### 1. Optimize Ambient Background Animation +**Problem:** The `AmbientBackground` controller was calling `resizeCanvas` inside the `requestAnimationFrame` loop. This function accessed `getBoundingClientRect()`, causing synchronous layout thrashing (forced reflow) on every frame, leading to high CPU/GPU usage. +**Fix:** +- Refactor `js/ui/ambientBackground.js` to use `ResizeObserver`. +- Only update canvas dimensions when the element actually resizes. +- Remove layout reads from the animation loop. + +### 2. Async Chunking for Explore Data Service +**Problem:** `ExploreDataService` performed heavy synchronous iterations over large datasets (Watch History and Video Tags) on the main thread. This could cause the UI to freeze (long tasks) during initialization or updates. +**Fix:** +- Refactor `buildWatchHistoryTagCounts` and `buildTagIdf` in `js/services/exploreDataService.js`. +- Implement processing in chunks (e.g., 500 items). +- Yield to the main thread using `setTimeout` between chunks to allow user interaction and frame rendering. + +### 3. Throttle URL Health Video Probes +**Problem:** The `UrlHealthController` spawned a `