Skip to content

chore: bump fig-extract to v2.26.2 - #42

Merged
onetwothr1 merged 2 commits into
devfrom
chore/vendor-fig-extract-2.26.2
Aug 4, 2026
Merged

chore: bump fig-extract to v2.26.2#42
onetwothr1 merged 2 commits into
devfrom
chore/vendor-fig-extract-2.26.2

Conversation

@onetwothr1

@onetwothr1 onetwothr1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

엔진 fig-extract.js v2.26.2src/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로 바뀌지 않습니다

releasePagespdfDocument로 넘긴 문서에만 적용되고 기본값이 꺼짐이며, tab-figures.ts는 이 옵션을 넘기지 않습니다. 즉 이 PR은 선언 + 파일 복사까지입니다.

기본값을 그렇게 둔 이유는, Margin이 넘기는 것이 사용자가 지금 보고 있는 뷰어의 살아 있는 문서이기 때문입니다. 엔진이 그 캐시를 비우면 뷰어의 다음 렌더가 재파싱을 물고, 뷰어가 그 페이지를 렌더하는 중이면 pdf.js가 지연 정리를 걸어 5초 뒤에 지웁니다.

켤지 판단이 필요한 항목 (후속 feat:)

FigRenderError(#12 → 엔진 백로그 B7)를 자주 만나는 환경이라면 releasePages: true가 그 압력을 낮추는 손잡이입니다. 엔진 repo 실측(330편 배치, --jobs 2):

렌더러 private 피크 FigRenderError
v2.26.1 5,407 MB 7건
v2.26.2 (releasePages 적용) 4,707 MB 1건

대가는 스캔 후 사용자가 그 페이지를 다시 볼 때 한 번 더 파싱하는 것뿐입니다. 다만 "스캔 직후 첫 렌더 지연 vs 메모리"는 Margin의 UX 트레이드오프라 이 PR에 넣지 않고 별도 변경으로 분리했습니다.

검증

  • src/core/fig-extract.js ↔ 엔진 repo 원본 sha256 일치(diff 0건)
  • VENDORED_ENGINE_VERSION 2.26.12.26.2 동일 커밋 갱신
  • npm run typecheck ✅ / npm test 48 passed (7 files) ✅ / npm run build
  • 엔진 repo 330편 전건(--jobs 2) — 이전 버전 스냅샷 대비 manifest 전수 diff 전 축 0
    (ADDED 0 · REMOVED 0 · MOVED>5pt 0 · 서브5pt/payload 0 · suspectedMissing 0)
  • check-crop-pixels PNG 2,238장 — 전면 투명 0 · 부분 회수 0 · 백지 0

머지 전 남은 것

  • Margin 스모크 테스트 (REQ-SMOKE) — 리뷰어가 수행
  • 벤더 원본 커밋 e9074cf는 엔진 repo feat/engine-page-cleanup 브랜치 tip이며 아직 main에 병합되지 않았습니다(엔진 repo main은 9dfe107). 병합 후 SHA가 바뀌면 커밋 본문 참조를 갱신해야 합니다.

engine: onetwothr1/PDFViewer-Figure-Extract@e9074cf

🤖 Generated with Claude Code

Summary by CodeRabbit

요약

  • 새 기능
    • 스캔 완료 후 PDF 페이지 캐시를 정리하는 releasePages 옵션이 추가되었습니다.
    • 캐시 정리 활성화 시 메모리 사용량을 줄일 수 있으며, 필요하면 페이지를 다시 처리할 수 있습니다.
    • 기본값은 비활성화되어 기존 출력과 동작에 영향을 주지 않습니다.
  • 개선 사항
    • 이미지 추출 엔진이 최신 버전으로 업데이트되었습니다.
  • 문서
    • 캐시 정리 옵션의 사용 조건과 메모리 절감 효과가 문서화되었습니다.

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>
@onetwothr1
onetwothr1 requested a review from enu3379 as a code owner August 4, 2026 02:00
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f30730b1-0e9e-4dc5-b940-3be3b6e73566

📥 Commits

Reviewing files that changed from the base of the PR and between c3c4d09 and fb14a72.

📒 Files selected for processing (1)
  • src/core/fig-extract.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/fig-extract.js

📝 Walkthrough

Walkthrough

fig-extract 엔진을 2.26.2로 갱신했습니다. releasePages 옵션으로 페이지 캐시 해제를 제어합니다. 엔진 소유 문서는 항상 정리하고, 호스트 제공 문서는 옵션이 활성화된 경우에만 정리합니다.

Changes

페이지 캐시 수명 관리

Layer / File(s) Summary
옵션 및 엔진 계약
src/core/fig-engine.ts, src/core/fig-extract.js, docs/fig-extract-integration.md
엔진 버전을 2.26.2로 갱신했습니다. ExtractOptions.releasePages를 추가했습니다. 기본값은 비활성화이며 추출 출력은 변경하지 않습니다.
페이지 처리 중 캐시 해제
src/core/fig-extract.js
인접 페이지와 캡션 페이지의 처리 후 페이지 캐시를 해제합니다. 렌더 및 오류 경로에서도 정리하며, 실패는 무시합니다.
엔진 소유 문서 정리
src/core/fig-extract.js
엔진이 직접 연 문서의 처리 완료 후 pdf.cleanup()을 호출합니다. 호스트 제공 문서의 소유권은 유지합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: enu3379

Poem

Poem

페이지를 살피는 작은 토끼,
끝난 캐시는 살며시 놓고,
필요한 문서는 끝까지 돌본다.
출력은 그대로 남겨 두고,
엔진은 cleanup으로 잠든다. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 vendored fig-extract 엔진을 v2.26.2로 갱신하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/vendor-fig-extract-2.26.2

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.js

ast-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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 80f53b3 and c3c4d09.

📒 Files selected for processing (3)
  • docs/fig-extract-integration.md
  • src/core/fig-engine.ts
  • src/core/fig-extract.js

Comment thread src/core/fig-extract.js Outdated
@onetwothr1

Copy link
Copy Markdown
Collaborator Author

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>
@onetwothr1

Copy link
Copy Markdown
Collaborator Author

@onetwothr1
onetwothr1 merged commit 8ade9e9 into dev Aug 4, 2026
3 checks passed
@onetwothr1
onetwothr1 deleted the chore/vendor-fig-extract-2.26.2 branch August 4, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant