Skip to content

Ticket-672: Fix blank PDF until window resize - #8231

Merged
david-yz-liu merged 3 commits into
masterfrom
TICKET-672_pdf_blank_until_resize
Oct 27, 2026
Merged

david-yz-liu merged 3 commits into
masterfrom
TICKET-672_pdf_blank_until_resize

Conversation

@Naragod

@Naragod Naragod commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

This fixes a blank PDF in the grading view. The page stays blank until the grader resizes the window. David asked to split #8228 in two. This PR holds the blank PDF fix.

The viewer hides itself while a file loads. pdf.js draws the pages a person can see. In a hidden pane, pdf.js finds zero pages to draw. A PDF with one page, such as a cover page, finishes while the pane is still hidden. The page then stays blank until a window resize forces a redraw.

In the code, file_viewer.jsx sets display: none while it loads. pdf.js fires pagesloaded before the pane shows. update_pdf_view then skips the refit.

  • pdf_viewer.jsx now watches its pane with a ResizeObserver.
  • When the pane shows, the viewer fits the pages to it.
  • When the pane changes width, the viewer fits the pages again.
  • After each fit, the viewer calls pdfViewer.update() to draw the pages in view.
  • pdf.js skips its own redraw when the scale stays the same, so the viewer makes this call itself.
  • The viewer tracks the pane's outer width, its border box.
  • A scrollbar that shows up after a fit leaves that width the same, so the fit runs once.

Verification

We ran these checks in Chromium on a local scanned exam. We ran them before the split, with the #8230 fix in place too.

Check Before After
Runs that forced the PDF to load while hidden, then left it blank 6 of 6 0 of 6
Zoom set to 150 %, kept after a switch Yes
Redraw loops on a window resize or a pane drag 0
Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
✨ New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
📖 Documentation update (change that updates documentation)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

@Naragod
Naragod requested a review from donny-wong October 23, 2026 15:00
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 39974016134

Coverage increased (+0.002%) to 91.049%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: 9 of 9 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 54015
Covered Lines: 50227
Line Coverage: 92.99%
Relevant Branches: 2569
Covered Branches: 1292
Branch Coverage: 50.29%
Branches in Coverage %: Yes
Coverage Strength: 127.5 hits per line

💛 - Coveralls

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 39974050132

Coverage increased (+0.002%) to 91.049%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: 9 of 9 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 54015
Covered Lines: 50227
Line Coverage: 92.99%
Relevant Branches: 2569
Covered Branches: 1292
Branch Coverage: 50.29%
Branches in Coverage %: Yes
Coverage Strength: 127.5 hits per line

💛 - Coveralls

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work @Naragod!

@david-yz-liu david-yz-liu added this to the v2.10.6 milestone Oct 27, 2026
@david-yz-liu
david-yz-liu merged commit a93062e into master Oct 27, 2026
14 checks passed
@david-yz-liu
david-yz-liu deleted the TICKET-672_pdf_blank_until_resize branch October 27, 2026 01:04
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.

4 participants