Skip to content

PDF Mobile: Fix stale pages and missing thumbnails after a PDF color scheme change - #275

Merged
mrtcode merged 2 commits into
zotero:masterfrom
Dima-Android:master
Nov 14, 2026
Merged

mrtcode merged 2 commits into
zotero:masterfrom
Dima-Android:master

Conversation

@Dima-Android

Copy link
Copy Markdown
Contributor

Three related problems when the PDF color scheme differs from the system one, or changes while the document is open:

  1. With the reader set to Light while the system is dark (or the reverse), the first pages rendered in the system scheme until setColorScheme() was called. A page that was still rendering at that point finished with the old theme and was never rendered again, so it stayed dark (or light) next to correctly themed pages.
  2. Thumbnails that were rendering when clear() ran kept an image in the previous scheme.
  3. Thumbnails that were requested but hadn't started rendering were dropped silently. Every render() call, and clear(), calls this._renderQueue.end(), which discards pending jobs. A host that requests one page per render() call never gets those thumbnails, so they stay on the loading spinner. This showed up as scrubber thumbnails stuck on spinners after a color scheme change or a document reload.

pdf-view.js

  • Seed _forcedColorScheme from options.colorScheme, so the first render already uses the requested scheme.
  • In _updateColorScheme(), reset every pdf.js page view that has started rendering. Previously only this._pages was reset, and it only contains pages that finished rendering.

pdf-thumbnails.js

  • Add a generation counter that clear() increments. A render that started before a clear() no longer stores its image.
  • Track requested and in-flight pages. clear() renders them again with the new scheme.
  • render() keeps not-yet-started requests when it ends the queue, instead of dropping them.

Dima-Android and others added 2 commits November 14, 2026 00:32
Keep native thumbnail requests on the existing queue while preserving desktop cancellation. Invalidate cached canvases and thumbnails synchronously.
@mrtcode
mrtcode merged commit 5581a8d into zotero:master Nov 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants