LazyPageLoader

LazyPageLoader

Lazily loads PDF/image page bitmaps and tracks high-res memory via an LRU.

Capacity is the maximum number of pages held at high resolution at once (default 8 ≈ 4 spreads). Requesting a page (ensurePageHighRes or via ensureSpreadLoaded) "touches" it, moving it to the most-recent slot; over-capacity entries at the oldest slot are evicted (bitmap closed, page.srcCanvas cleared). Previews are kept loaded indefinitely — they're cheap and the page strip depends on them.

Eviction can be deferred via setEvictionsDeferred(true) to avoid closing a bitmap whose texture is still in use by an in-flight WebGPU animation. Call flushEvictions() (or setEvictionsDeferred(false)) once it's safe.