Repository navigation
Cancel superseded PDF renders so a stale zoom can't paint the page - #44
Merged
Merged
Conversation
A page re-renders each time its scale changes. When a render was cancelled, its catch block cleared _renderTask even though that field already pointed at the newer render. The next scale change then couldn't cancel it: it resized the canvas under the still-running render, and pdf.js rejected the new render because the canvas was in use. The stale render finished drawing at the old zoom. Only clear _renderTask when it still holds this call's own task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pages loop in the canvas template closed with `)})`, leaving a literal ")" in the container under the last page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jdmcleod
approved these changes
Oct 7, 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.
Why
On slower machines the PDF viewer could open a page drawn at the wrong zoom or garbled, while the toolbar showed the right percentage, until the user zoomed out and back in. A cancelled render was clearing the handle that already belonged to the newer render. The next zoom change then couldn't cancel that render, and the stale one painted over the canvas. Now each render only clears its own handle, so every superseded render is cancelled.
A page load changes zoom two or three times in quick succession (default, fit-to-width, refit on resize), which is why this shows up on page open and not just on manual zooming.
What Changed
)rendered below the pagesScreenshots
Demo page with a heavy vector PDF, three back-to-back zoom changes, 6× CPU throttle. Both show 110% in the toolbar. Before, pdf.js also logs "Cannot use the same canvas during multiple render() operations".
🤖 Generated with Claude Code