Auds/lazy loading: Added support for the lazy loading for the range-served / linearized PDFs, fixed caching bug on 2.2.24 - #692
Open
Satendra9984 wants to merge 6 commits into
Conversation
reloadPages reads the page list after its await and writes it back synchronously, so concurrent calls cannot interleave and the queue that serialised them was unnecessary. It was also harmful: one measurement that faulted a block and waited on the network held up every other visible page behind it, so a single slow page blanked the whole screen instead of itself. The duplicate-request behaviour that motivated the queue had a different cause -- _onDocumentChanged clears the in-flight set on every reset, and the progress-notification reset storm was still running at the time. Also replace the permanent measurement blacklist with a three-attempt budget, and only count a failure when the viewer and document are still the ones that asked. A throw during teardown says nothing about whether a page is readable, and blacklisting on it left that page blank for the rest of the session. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drives the real engine through a range-aware MockClient so the demand-paging path is exercised rather than a stand-in, with knobs for latency, servers that ignore Range, and forced failures. Not yet passing: HTTP fires but the document never materialises. Two known harness issues are documented in the file -- the load error is swallowed, and PdfDocumentRef._listenables is a static registry that leaks a loaded document between tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A sequential run of measurements looks identical whether the viewport is moving through the document or something is walking it, so the trace could not distinguish the two. Record the first and last page in the render cache extent at the moment the request is made. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…es subsequent rendering as white pags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Large remote PDFs with
preferRangeAccess: truestill blocked first paint untilevery page was measured. Measurement walks each page dictionary; on linearized
files those dictionaries are spread across the file, so the viewer faulted the
whole file (1 MB blocks, serialized) before painting page 1.
This PR adds an opt-in path (
loadPageDimensionsOnDemand, defaultfalse)that measures only pages entering the existing render-cache extent, plus related
correctness fixes that show up once range access continues for the document lifetime.
Based on tag
pdfrx-v2.2.24(not rebased onto current master). Happy to rebaseif preferred.
Changes
PdfViewerBehaviorControlParams.loadPageDimensionsOnDemand):skip exhaustive
loadPagesProgressively; measure visible pages viareloadPages;fire
onDocumentLoadFinishedwhen the progressive pass is skipped.reloadPagessubset fix: apply worker results bypageIndex(was using list position).Pdfrx.debugLazyLoading/ fetch byte counters; tests with real PDFium over a fake Range-aware HTTP client + fixture.Trade-offs when the flag is on
loadTextonly covers measured pages.Motivation / deeper write-up: handwritten-notes demand paging in a Flutter app
serving large chapter PDFs over HTTP range requests.
Test plan
loadPageDimensionsOnDemand: false) behavior unchanged.preferRangeAccess: true+ flag on → early first paint; progressive MEASURE logs.PDFIUM_PATH=... flutter test packages/pdfrx/test/lazy_loading_test.dart