[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,91 +2,199 @@
id: wiki-2026-0508-long-animation-frames-api
title: Long Animation Frames API
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-2A8383]
aliases: [LoAF, Long Animation Frames, LongAnimationFrameTiming]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
tags: [auto-reinforced]
verification_status: applied
tags: [web-performance, loaf, long-tasks, inp, scripting-attribution]
raw_sources: []
last_reinforced: 2026-04-20
github_commit: "[P-Reinforce] Continuous Worker - Long Animation Frames API"
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
last_reinforced: 2026-05-10
github_commit: pending
tech_stack: { language: js, framework: web-api }
---
# [[Long Animation Frames API]]
# Long Animation Frames API
## 📌 한 줄 통찰 (The Karpathy Summary)
> Long Animation Frames API는 사용자 상호작용을 지연시키는 스크립트를 식별하고 세부 정보를 제공하는 데 사용되는 웹 성능 API입니다 [1]. [[Chrome]] 브라우저에서 INP(Interaction to Next Paint) 지표 측정을 위한 계측(instrumentation) 역할을 하여, 특정 상호작용 중에 실행된 자바스크립트 목록을 제공합니다 [2]. 이를 통해 개발자는 열악한 사용자 경험을 유발하는 스크립트와 함수를 효과적으로 탐지하고 최적화할 수 있습니다 [2].
## 한 줄
> **"매 Long Tasks 의 후계자"**. 50ms+ frame 을 잡고 어떤 script 가 원인인지 attribution 까지 — INP 디버깅의 핵심.
## 📖 구조화된 지식 (Synthesized Content)
* **상호작용 처리 시간 및 스크립트 식별:** 이 API는 사용자의 입력(클릭, 탭, 포인터 등)에 대한 직접적 또는 간접적인 결과로 실행된 이벤트 리스너나 콜백 등의 스크립트 목록을 식별하게 해줍니다 [2]. [[Chrome DevTools]]에서 INP 값을 분석할 때, 이 API 덕분에 상호작용 처리 시간에 기여한 자바스크립트 코드의 상세 목록을 콘솔에서 확인할 수 있습니다 [2].
* **성능 모니터링 도구에서의 활용:** DebugBear와 같은 웹 성능 모니터링 제품은 Long Animation Frames API에서 얻은 데이터를 활용하여 사용자 상호작용을 지연시키는 스크립트를 시각화합니다 [1]. 이를 통해 각 스크립트를 파비콘, 실행 이유에 대한 설명, 그리고 스크립팅 작업과 레이아웃 작업의 세부 항목으로 분류하여 표시할 수 있습니다 [1].
* **INP(Interaction to Next Paint) 문제 해결:** 웹 사이트의 반응성을 측정하는 핵심 지표인 INP의 하위 요소 중 '처리 시간([[Processing]] duration)'의 지연 원인을 분석할 때 매우 중요하게 활용됩니다 [2, 3].
## 매 핵심
### 매 vs Long Tasks
| | Long Tasks | Long Animation Frames (LoAF) |
|---|---|---|
| 단위 | 단일 task | rendering frame 전체 (start ~ render) |
| Threshold | 50ms+ | 50ms+ frame duration |
| Attribution | 거의 없음 | scripting source URL, invoker, function |
| Render 정보 | 없음 | renderStart, styleAndLayoutStart, paint |
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
- **정책 변화:** AI 분야의 자동 자산화 수행.
### 매 timing 분해
- `startTime` → frame 시작
- `renderStart` → render phase 시작
- `styleAndLayoutStart` → style/layout 시작
- `duration` → 총 frame
- `blockingDuration` → blocking 시간
- `scripts[]` → 어떤 스크립트가 얼마나 점유
## 🔗 지식 연결 (Graph)
- **Related Topics:** INP (Interaction to Next Paint), [[Chrome DevTools]], Web Performance
- **Projects/Contexts:** 사용자 상호작용 병목 현상을 파악하기 위한 [[Chrome DevTools]] 성능 패널 및 DebugBear 웹 성능 모니터링 대시보드
- **Contradictions/Notes:** 소스에 모순되는 내용은 존재하지 않으며, 이 API는 웹 성능 분석 및 서드파티 모니터링 서비스에서 자바스크립트 실행 지연을 식별하는 주요 수단으로 일관되게 설명되고 있습니다.
### 매 응용
1. INP regression 디버깅
2. 3rd-party script 영향 정량화
3. Hydration cost 측정 (Next/Nuxt)
4. RUM 에 attribution 보내기
5. Frame budget violation 알림
---
*Last updated: 2026-04-19*
## 💻 패턴
---
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
### Pattern 1: Basic observer
```js
const obs = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.duration < 50) continue;
console.log({
duration: entry.duration,
blocking: entry.blockingDuration,
renderStart: entry.renderStart,
scripts: entry.scripts.map(s => ({
name: s.name,
invoker: s.invoker,
source: s.sourceURL,
duration: s.duration,
})),
});
}
});
obs.observe({ type: "long-animation-frame", buffered: true });
```
## 🤔 의사결정 기준 (Decision Criteria)
### Pattern 2: Send to RUM with worst script
```js
new PerformanceObserver((list) => {
for (const e of list.getEntries()) {
const worst = e.scripts.reduce((a, b) => b.duration > a.duration ? b : a, { duration: 0 });
sendBeacon("/rum/loaf", JSON.stringify({
url: location.href,
duration: e.duration,
blocking: e.blockingDuration,
worstScript: worst.sourceURL,
worstFn: worst.invoker,
}));
}
}).observe({ type: "long-animation-frame", buffered: true });
```
**선택 A를 써야 할 때:**
- *(TODO)*
### Pattern 3: Budget violation alarm
```js
const FRAME_BUDGET_MS = 100;
**선택 B를 써야 할 때:**
- *(TODO)*
new PerformanceObserver((list) => {
for (const e of list.getEntries()) {
if (e.duration > FRAME_BUDGET_MS) {
reportBudgetMiss({
duration: e.duration,
scripts: e.scripts.map(s => s.sourceURL),
});
}
}
}).observe({ type: "long-animation-frame", buffered: true });
```
**기본값:**
> *(TODO)*
### Pattern 4: 3rd-party attribution
```js
function attributeScript(s) {
const u = new URL(s.sourceURL || location.href);
if (u.hostname === location.hostname) return "first-party";
if (/google|facebook|hotjar|segment/.test(u.hostname)) return "analytics";
return u.hostname;
}
## ❌ 안티패턴 (Anti-Patterns)
new PerformanceObserver((list) => {
const buckets = {};
for (const e of list.getEntries())
for (const s of e.scripts) {
const k = attributeScript(s);
buckets[k] = (buckets[k] || 0) + s.duration;
}
console.table(buckets);
}).observe({ type: "long-animation-frame", buffered: true });
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### Pattern 5: Hydration measurement
```js
let hydrationFrames = [];
new PerformanceObserver((list) => {
if (performance.now() < 5000) { // 첫 5s = hydration phase 가정
hydrationFrames.push(...list.getEntries());
}
}).observe({ type: "long-animation-frame", buffered: true });
window.addEventListener("load", () => {
console.log("Hydration LoAFs:", hydrationFrames.length,
"total blocking:", hydrationFrames.reduce((s, e) => s + e.blockingDuration, 0));
});
```
### Pattern 6: Tie LoAF to INP event
```js
let recentLoafs = [];
new PerformanceObserver(list => {
recentLoafs.push(...list.getEntries());
recentLoafs = recentLoafs.slice(-20);
}).observe({ type: "long-animation-frame", buffered: true });
new PerformanceObserver(list => {
for (const ev of list.getEntries()) {
const overlapping = recentLoafs.filter(l =>
l.startTime <= ev.startTime + ev.duration && l.startTime + l.duration >= ev.startTime
);
console.log("INP", ev.duration, "overlapping LoAFs:", overlapping);
}
}).observe({ type: "event", durationThreshold: 40 });
```
### Pattern 7: Feature detection
```js
const supportsLoAF = PerformanceObserver.supportedEntryTypes?.includes("long-animation-frame");
if (supportsLoAF) { /* observe */ }
else { /* fallback to long-task */ }
```
## 매 결정 기준
| 상황 | API |
|---|---|
| INP debugging | LoAF (attribution 필수) |
| 단순 long task 개수 | longtask 도 충분 |
| Production RUM | LoAF (worst script만 전송) |
| 3rd-party 영향 분석 | LoAF |
| 호환성 필요 | LoAF + longtask fallback |
**기본값**: LoAF observer + RUM beacon + budget alarm.
## 🔗 Graph
- 부모: [[Web_Performance]], [[Performance_API]]
- 변형: [[Long_Tasks_API]] (구세대)
- 응용: [[INP]], [[Core_Web_Vitals]]
- Adjacent: [[Lighthouse]], [[RUM]]
## 🤖 LLM 활용
**언제**: LoAF dump → "어떤 script 가 가장 비용 비싼가" 분석, 패턴 인식.
**언제 X**: 실시간 sampling 결정 (deterministic threshold), 보안 critical attribution (cross-origin source 제한).
## ❌ 안티패턴
- 모든 LoAF 를 서버로 전송 → bandwidth 폭발 (worst만 전송)
- Long Task 만 보고 INP 디버깅 → 원인 못 찾음
- `buffered: true` 안 씀 → 초기 frame 놓침
- Feature detection 없이 사용 → 구 브라우저 throw
- Cross-origin script `sourceURL` 가려짐 무시 → "(unknown)" 비율 보고
## 🧪 검증 / 중복
- Verified (W3C LongAnimationFrameTiming spec, web.dev/articles/long-animation-frames). 신뢰도 A.
- Chrome 123+ 안정 지원, Safari/Firefox 진행 중 (2026-05 기준).
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — vs LongTasks, attribution + INP correlation patterns |