Three plans for Phase 8 (分页质量、缓存与性能采样): - 08-01: Pagination cache key struct and manager stub (QUAL-01) - 08-02: Unified 1080x1920 max-size constraint for all images, footnote width-only sizing (QUAL-02, QUAL-03, QUAL-04) - 08-03: Pagination timing instrumentation with [EPUB][Perf] diagnostic output (QUAL-04) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5.6 KiB
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 08-pagination-quality-cache-performance | 01 | execute | 1 |
|
true |
|
|
Purpose: Prevents the same chapter from being fully re-typeset when viewport and typography config haven't changed (QUAL-01).
Output: RDEPUBTextRendererCache.swift with cache key struct and manager stub.
<execution_context> @$HOME/.claude/get-shit-done/workflows/execute-plan.md @$HOME/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/08-pagination-quality-cache-performance/08-CONTEXT.md @.planning/phases/08-pagination-quality-cache-performance/08-RESEARCH.mdFrom Sources/RDReaderView/EPUBTextRendering/RDEPUBDTCoreTextRenderer.swift:
RDEPUBTextChapterRenderRequest— containsstyle: RDEPUBTextRenderStyle,contextwith baseURLRDEPUBTextRenderStyle— hasfont: UIFont,lineSpacing: CGFloat,textColor: UIColor?,backgroundColor: UIColor?
From Sources/RDReaderView/EPUBTextRendering/RDEPUBTextRendererSupport.swift:
RDEPUBTextRenderStyleproperties used in rendering:font.pointSize,font.familyName,font.fontName,lineSpacing
-
RDEPUBPaginationCacheKeystruct — captures the inputs that determine pagination output:chapterID: String(unique chapter identifier, e.g. href or file path)viewportSize: CGSize(the available page dimensions)fontDescriptor: String(font family + name + pointSize, concatenated)lineSpacing: CGFloattextColorHash: Int?(hash of textColor, if present)- Implement
Equatableconformance (auto-synthesize is fine)
-
RDEPUBTextRendererCacheclass:static let shared = RDEPUBTextRendererCache()private var cache: [RDEPUBPaginationCacheKey: [NSAttributedString]]— maps key to array of page attributed stringsfunc cachedPages(for key: RDEPUBPaginationCacheKey) -> [NSAttributedString]?— returns cached pages or nilfunc store(pages: [NSAttributedString], for key: RDEPUBPaginationCacheKey)— stores pagesfunc invalidate(for key: RDEPUBPaginationCacheKey)— removes a specific entryfunc invalidateAll()— clears entire cachevar entryCount: Int— read-only count of cached entries (for diagnostics)
Make the class final and Sendable-safe (use a lock or @MainActor annotation since rendering is main-thread). Use NSLock for thread safety.
Do NOT wire this cache into the rendering pipeline yet — that is future work. This plan only creates the infrastructure.
xcodebuild build -project ReadViewDemo/ReadViewDemo.xcodeproj -scheme ReadViewDemo -destination 'platform=iOS Simulator,name=iPhone 16' 2>&1 | tail -5
<acceptance_criteria>
- Sources/RDReaderView/EPUBTextRendering/RDEPUBTextRendererCache.swift exists
- File contains struct RDEPUBPaginationCacheKey: Equatable with properties: chapterID, viewportSize, fontDescriptor, lineSpacing, textColorHash
- File contains final class RDEPUBTextRendererCache with static shared instance
- Class has methods: cachedPages(for:), store(pages:for:), invalidate(for:), invalidateAll()
- Class has computed property entryCount: Int
- Build succeeds (xcodebuild exits 0)
</acceptance_criteria>
Cache key struct and cache manager stub exist, build compiles successfully
<success_criteria>
- RDEPUBPaginationCacheKey captures all inputs that affect pagination output
- RDEPUBTextRendererCache provides a thread-safe, singleton cache surface ready for wiring
- No existing code is modified — this is purely additive </success_criteria>