Repository navigation
fix(document): find a hinted page's index without the page tree (#410) - #413
Merged
Merged
Conversation
RemoteFirstPageTests timed out intermittently in the blazor-wasm job. The cause was a real bug, not slowness. For a remote linearized file, the viewer's text selection and accessibility loads call PdfPage.ExtractLayout, which asked PdfPageCollection.IndexOf for the page's index. IndexOf walked the whole page tree, which needs the main cross-reference section at the end of the file. The browser cannot fetch that synchronously, so every page's load failed with a PdfRangeNotLoadedException. The Blazor sample showed that error as a message above the viewer. The message resized the viewer, and InputModel.Resize stops a running page animation, so the test's End key jump stopped at whatever page it had reached (page 2 in the captured CI failure). The test passed only when the message appeared before the key press. While the hint tables locate the pages, IndexOf and TryGetPage now answer from the pages the hints handed out (F.3.7: hinted pages are in page order), and fall back to the page tree for anything else. Tests: a core test extracts the layout of pages 1, 2 and 30 of a remote linearized file with synchronous fetching off and no request beyond each page's prefetch; a viewer test loads links, text and the accessible tree of those pages through a cooperative remote session; the browser test now waits for page 1's text layer, asserts the viewer reported no error, and runs in Chromium, WebKit and Firefox. The new browser assertion fails 10 of 10 times against the old app; all of them pass after the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
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.
Closes #410.
Root cause (a viewer bug, not a slow runner)
The CI failure was captured with a diagnostic build of the test (dispatched
blazor-wasmruns on this branch). In 1 of 18 attempts, the viewer stopped at page 2 with frames idle. The sample showed this message above the viewer:Those bytes are the main cross-reference section at the end of the linearized file. The chain:
PdfPage.ExtractLayout, which asksPdfPageCollection.IndexOffor the page's index.IndexOfwalked the whole page tree. That needs the main cross-reference section and every tree node, and neither is part of a hinted page's prefetch. In the browser, synchronous range fetching is off, so this threwPdfRangeNotLoadedException. It failed for every page of a remote linearized file, in every run..messagebanner above the viewer. The banner resizes the viewer, andInputModel.Resizestops a running scroll animation. The test'sEndjump therefore stopped wherever it was.Fix
While the hint tables locate the pages,
PdfPageCollection.IndexOf(CosDictionary)andTryGetPagenow answer from the pages the hints handed out. F.3.7 guarantees that hinted pages are in page order, the same orderthis[int]already uses. Anything the hints did not hand out still goes through the page tree.HintedPageListrecords each handed-out page object's index.Tests
FirstPageFirstTests.A_hinted_page_finds_its_index_and_extracts_its_layout_without_the_page_tree(Table and Stream xref layouts): with synchronous fetching off, pages 1, 2 and 30 return their index and extract their layout, with no request beyond each page's prefetch. Red before the fix (PdfRangeNotLoadedException), green after.DocumentSessionTests.A_remote_linearized_page_loads_its_links_text_and_accessible_tree_without_synchronous_fetches(pages 0, 1, 29): a cooperative remote session, as in the browser. Red 3/3 before, green 3/3 after.RemoteFirstPageTests: the test now waits until page 1's text layer has loaded (still behind the gate) and asserts that the viewer reported no error, both before the jump and at the end. It runs in Chromium, WebKit and Firefox. Against the pre-fix app the new assertion fails deterministically (10/10), so a regression can no longer show up as a flake.Pass rates
Firefox could not be launched inside the local agent sandbox, so it runs in CI only.
Follow-up (not in this PR)
InputModel.Resizestops a page jump in flight. Any banner or toolbar that appears during a jump cancels it. That is arguably a separate UX issue, and it is noted inflaky-tests.md.🤖 Generated with Claude Code