chore: bump fig-extract to v2.26.2 - #42
Conversation
engine: onetwothr1/PDFViewer-Figure-Extract@e9074cf 엔진 `fig-extract.js` v2.26.2를 `src/core/`로 byte-identical 복사하고 `VENDORED_ENGINE_VERSION`을 함께 갱신했다. 계약 태그 `[필드 추가: optional opts.releasePages]` — 소비자 측 대응(`fig-engine.ts` `ExtractOptions` 선언 + `docs/fig-extract-integration.md` §주의사항)은 같은 커밋에 있다 (선언과 파일 복사를 갈라 두면 타입만 앞서 나간 상태가 초록으로 통과한다 — 이 문서 §부분집합 원칙). 엔진 변경 요지: 스캔이 끝난 페이지의 pdf.js 캐시(디코드된 이미지)를 `page.cleanup()`으로 반환한다. 엔진은 지금까지 이걸 한 번도 부르지 않아 문서를 다 훑을 때까지 전 페이지의 디코드 결과가 함께 상주했고(40MB PDF 한 편이 렌더러 2.4GB, 130MB가 3.9GB), pdf.js가 operator list와 display에 다른 캐시 키를 써서 캡션 페이지마다 **같은 이미지가 두 벌** 남아 있었다. `figures`·크롭 출력은 불변 — 비우는 것은 캐시뿐이다. **Margin 런타임 동작은 이 커밋으로 바뀌지 않는다.** `releasePages`는 `pdfDocument`로 넘긴 문서에만 적용되고 기본값이 꺼짐이며, `tab-figures.ts`는 이 옵션을 넘기지 않는다. 뷰어의 살아 있는 문서 캐시를 엔진이 비우면 다음 렌더가 재파싱을 물기 때문에 기본값을 그렇게 두었다. 켤지 판단은 UX 트레이드오프(스캔 후 첫 렌더 지연 vs 메모리)라 별도 `feat:` 변경으로 분리한다. 검증: - `src/core/fig-extract.js` ↔ 엔진 repo 파일 sha256 일치 (diff 0건) - `npm run typecheck` / `npm test` 48 passed (7 files) / `npm run build` 통과 - 엔진 repo 330편 전건(`--jobs 2`): manifest 전수 diff ADDED 0 · REMOVED 0 · MOVED>5pt 0 · 서브5pt/payload 0 · suspectedMissing 0, `check-crop-pixels` PNG 2,238장 의심 0건. 같은 배치에서 렌더러 private 피크 5,407 → 4,707MB, `FigRenderError` 7건 → 1건. ⚠ 벤더 원본 커밋 `e9074cf`는 엔진 repo의 `feat/engine-page-cleanup` 브랜치 tip이며 아직 `main`에 병합되지 않았다(엔진 repo main은 `9dfe107`). 병합 후 SHA가 바뀌면 이 본문의 참조를 갱신해야 한다. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughfig-extract 엔진을 2.26.2로 갱신했습니다. Changes페이지 캐시 수명 관리
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.45.0)src/core/fig-extract.jsast-grep timed out on this file Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/fig-extract.js`:
- Around line 5183-5187: Wrap the engine-owned PDF lifecycle after creation of
pdf through return in a try/finally, and move the existing !opts.pdfDocument
cleanup into finally so it runs on success, exceptions, and cancellation across
document loading, page analysis/rendering, adjacent-page observation, and
diagnostics. Preserve the existing behavior for host-provided documents and
ignore cleanup failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0be16175-f79b-4e32-afd6-e1ed4992fd16
📒 Files selected for processing (3)
docs/fig-extract-integration.mdsrc/core/fig-engine.tssrc/core/fig-extract.js
|
|
engine: onetwothr1/PDFViewer-Figure-Extract@4f2ae72 CodeRabbit이 이 PR에서 잡은 Major 건 반영본을 다시 벤더링한다. **버전은 2.26.2 그대로**이고 (아직 병합 전인 같은 릴리스에 대한 수정이라 엔진 repo에서 별도 번호를 붙이지 않았다) `VENDORED_ENGINE_VERSION`도 변경 없다. 무엇이 바뀌었나: 엔진의 문서 단위 정리(`pdf.cleanup()`)가 **성공 반환 직전에서만** 돌고 있어, 페이지 렌더·12-B 관측·진단 마감 중 어디서든 예외나 AbortError가 나면 `commonObjs`(전역 캐시 이미지·폰트·CMap)가 그대로 남았다. 하필 실패 경로가 곧 메모리 압력 경로(`FigRenderError`는 정의상 메모리가 모자랄 때 난다)라, 정리가 가장 필요한 순간에만 건너뛰는 구조였다. 문서 소유를 얇은 래퍼로 분리해 try/finally로 정리한다. **Margin 런타임 동작은 이 커밋으로도 바뀌지 않는다** — 이 정리는 `!opts.pdfDocument` (엔진이 직접 연 문서)에만 적용되고, `tab-figures.ts`는 뷰어 문서를 넘긴다. 그 문서의 수명은 이전과 동일하게 호스트 몫이다. 검증: - `src/core/fig-extract.js` ↔ 엔진 repo 원본 sha256 일치 (diff 0건) - `npm run typecheck` / `npm test` 48 passed / `npm run build` 통과 - 엔진 repo 330편 `--jobs 3` 전건: 완주 330/330 · 오류 0 · manifest 전수 diff 전 축 0 · check-crop-pixels PNG 2,238장 의심 0건 · 단위 테스트 31/31(실패 경로 회귀 테스트 신규) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
엔진
fig-extract.jsv2.26.2를src/core/로 벤더링합니다. 계약 태그는[필드 추가: optional opts.releasePages]입니다.메모리 최적화
기존: Margin 뷰어 탭 메모리 사용량 최대 3GB -> 개선 후 500MB
스캔이 끝난 페이지의 pdf.js 캐시(디코드된 이미지)를
page.cleanup()으로 반환합니다. 엔진은 지금까지 이 호출을 한 번도 하지 않아 문서를 다 훑을 때까지 전 페이지의 디코드 결과가 함께 상주했습니다 — 40MB PDF 한 편이 렌더러 2.4GB, 130MB가 3.9GB였습니다.pdf.js는 operator list와 display에 서로 다른 캐시 키를 쓰고 objId 카운터를 리셋하지 않기 때문에, 캡션 페이지마다 같은 이미지가 두 번 디코드되어 두 벌이 동시에 상주하고 있었습니다. 렌더 직전에 한 벌을 놓아주는 것만으로 페이지 내부 피크가 대략 절반이 됩니다.
figures·크롭 출력은 불변입니다 — 비우는 것은 캐시뿐이고 이후 다시 필요하면 pdf.js가 재파싱합니다.Margin 런타임은 이 PR로 바뀌지 않습니다
releasePages는pdfDocument로 넘긴 문서에만 적용되고 기본값이 꺼짐이며,tab-figures.ts는 이 옵션을 넘기지 않습니다. 즉 이 PR은 선언 + 파일 복사까지입니다.기본값을 그렇게 둔 이유는, Margin이 넘기는 것이 사용자가 지금 보고 있는 뷰어의 살아 있는 문서이기 때문입니다. 엔진이 그 캐시를 비우면 뷰어의 다음 렌더가 재파싱을 물고, 뷰어가 그 페이지를 렌더하는 중이면 pdf.js가 지연 정리를 걸어 5초 뒤에 지웁니다.
켤지 판단이 필요한 항목 (후속
feat:)FigRenderError(#12 → 엔진 백로그 B7)를 자주 만나는 환경이라면releasePages: true가 그 압력을 낮추는 손잡이입니다. 엔진 repo 실측(330편 배치,--jobs 2):FigRenderErrorreleasePages적용)대가는 스캔 후 사용자가 그 페이지를 다시 볼 때 한 번 더 파싱하는 것뿐입니다. 다만 "스캔 직후 첫 렌더 지연 vs 메모리"는 Margin의 UX 트레이드오프라 이 PR에 넣지 않고 별도 변경으로 분리했습니다.
검증
src/core/fig-extract.js↔ 엔진 repo 원본 sha256 일치(diff 0건)VENDORED_ENGINE_VERSION2.26.1→2.26.2동일 커밋 갱신npm run typecheck✅ /npm test48 passed (7 files) ✅ /npm run build✅--jobs 2) — 이전 버전 스냅샷 대비 manifest 전수 diff 전 축 0(
ADDED 0 · REMOVED 0 · MOVED>5pt 0 · 서브5pt/payload 0 · suspectedMissing 0)check-crop-pixelsPNG 2,238장 — 전면 투명 0 · 부분 회수 0 · 백지 0머지 전 남은 것
e9074cf는 엔진 repofeat/engine-page-cleanup브랜치 tip이며 아직main에 병합되지 않았습니다(엔진 repo main은9dfe107). 병합 후 SHA가 바뀌면 커밋 본문 참조를 갱신해야 합니다.engine: onetwothr1/PDFViewer-Figure-Extract@e9074cf
🤖 Generated with Claude Code
Summary by CodeRabbit
요약
releasePages옵션이 추가되었습니다.