Discard rendered pages while the reader is in a hidden tab#229
Open
pistachionet wants to merge 1 commit into
Open
Discard rendered pages while the reader is in a hidden tab#229pistachionet wants to merge 1 commit into
pistachionet wants to merge 1 commit into
Conversation
Adds Reader.setSuspended(), which for PDF views destroys all page views to release page canvases, snapshot canvases, extracted page data, and worker-side page resources, and pauses the rendering queue so nothing re-renders while hidden. On resume, rendering is unpaused and visible pages re-render through the normal path. Each loaded reader view otherwise retains 10+ rendered page canvases (roughly 30-60 MB each on HiDPI displays) plus a same-size snapshot copy of each, indefinitely. Also explicitly zero snapshot canvas backing stores when a page is destroyed, instead of waiting for GC. Requires the PDFRenderingQueue paused flag from the zotero/pdf.js companion PR.
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.
Each loaded PDF view retains at least 10 fully rendered page canvases (
PDFPageViewBuffer,DEFAULT_CACHE_SIZE = 10— the buffer never shrinks below that). On a 2x HiDPI display at page-width zoom a page canvas is ~2400×3100 device pixels ≈ 30 MB RGBA, up to themaxCanvasPixels = 2^25cap. On top of that, the annotation overlay renderer (src/pdf/page.js) keeps a full-size_snapshotCanvascopy of every rendered page canvas (captured unconditionally in_maybeRefreshSnapshot(), even for pages with no annotations), plus extracted per-page data in_pdfPages. That's roughly 600 MB per loaded PDF tab, retained indefinitely while the tab is hidden, since nothing is released on tab deselection.This pr adds Reader.setSuspended(), which for PDF views destroys all page views to release page canvases, snapshot canvases, extracted page data, and worker-side page resources, and pauses the rendering queue so nothing re-renders while hidden. On resume, rendering is unpaused and visible pages re-render through the normal path.
Each loaded reader view otherwise retains 10+ rendered page canvases (roughly 30-60 MB each on HiDPI displays) plus a same-size snapshot copy of each, indefinitely.
Also explicitly zero snapshot canvas backing stores when a page is destroyed, instead of waiting for GC.
Requires the PDFRenderingQueue paused flag from the zotero/pdf.js companion PR.