Skip to content

Stop thumbnail helpers when their images are discarded - #117

Closed
k-kostin wants to merge 4 commits into
omacom:mainfrom
k-kostin:codex/cancel-thumbnail-requests
Closed

k-kostin wants to merge 4 commits into
omacom:mainfrom
k-kostin:codex/cancel-thumbnail-requests

Conversation

@k-kostin

@k-kostin k-kostin commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rebased independently onto f73d8e4 after #216–218. Pass discarded image requests' cancellation flag through thumbnailer, PDF and sharp-preview fallback work. Poll the existing helper deadline in at most 100 ms slices, and use main's existing process-group cleanup when cancelled.

discard image → cancel helper → skip cache/marker → serve next image

#218's result delivery before PNG encoding/cache writes, request priorities and lazy thumbnailer setup remain intact. No new worker, renderer or dependency.

Evidence

  • The same real-QML regression fills all workers with 2.5-second helpers, discards their images and requires a replacement image within one second. It covers an installed thumbnailer, Poppler fallback and sharp-PDF fallback. Helpers create valid PNGs before waiting; after cancellation all thumbnail buckets and failure markers must remain empty for those sources.
  • On unmodified main, all three rows fail the one-second bound and need about 2.5 seconds. The candidate passes, including an unlimited helper deadline and a slow TMPDIR.
  • Final Release build and complete local tests: 282 passed, 0 failed, 1 skipped (the existing root-drive trash test requires a writable / without .Trash). Qt 6.12.0, private settings/session bus, offscreen rendering and package-owned image plugins.
  • Two fresh Astra reviews found a missing cache-bucket check and an unlimited-deadline edge. Both were fixed and the final delta reviewed without remaining blockers. git diff --check passes.

Merge Danger

Door: two-way; no cache migration.

Blast Radius: external thumbnail helpers.

Uses main's existing process groups and patience limit. In-process image decoding remains non-interruptible; cancellation is checked before publishing its result.

@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks, Kirill. Stopping a helper once nobody wants its picture is worth having. But this is stacked on #67's helper machinery (run(), Ran, the kept sessions, m_quitting), and none of that is on main: main's thumbnailers and pdftoppm still run under a plain waitForFinished(15000). The rows-thumbnail part of #67 landed separately in #149, and #67 itself is still open, so this can't be reviewed against what will actually ship.

To make it mergeable, please rebase it onto main on its own, without #67. On main the change can be small: wait for the helper in short slices, kill it when the response's m_cancelled is set, and don't write a failure marker for a cancelled run. Keep one test that fails without the change, such as thumbnailsStopWorkWhenItsImagesGoAway. Then mark it ready. If #67 lands first, rebasing onto that works just as well.

@k-kostin
k-kostin force-pushed the codex/cancel-thumbnail-requests branch from 8f833ec to 84ad9fe Compare November 18, 2026 14:57
@k-kostin
k-kostin changed the base branch from thumbnail-rows to main November 18, 2026 14:58
@k-kostin
k-kostin marked this pull request as ready for review November 18, 2026 14:58
@k-kostin

Copy link
Copy Markdown
Contributor Author

Thanks for the clear direction. Reworked this independently on main 7c058ce in 84ad9fe, without #67's helper/session machinery. Both existing helper paths now use short cancellable waits, and cancelled runs leave no thumbnail or failure marker. The sharp-preview fallback carries the same flag.

Kept one QML regression, thumbnailsStopWorkWhenItsImagesGoAway: it fails on main and passes with this change. The final local full suite reports 233 passed, 0 failed and one permissions-dependent skip with the package image-plugin set. Release build and independent reviews passed. The PR now targets main and is ready for review.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR stops external thumbnail helpers when their images are discarded.

  • Discarded image requests stop holding thumbnail workers.

No actionable issues were found. Tests were not run during this review because Qt was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Image discarded] --> B[Set cancellation flag]
  B --> C[Helper wait sees cancellation]
  C --> D[Kill helper process group]
  D --> E[Skip cache and failure marker]
  E --> F[Worker serves next image]
Loading

Reviews (3) · Last reviewed commit: "Cover all cache buckets and cancellation..." · Reviewed by Greptile

@dhh
dhh force-pushed the codex/cancel-thumbnail-requests branch from 84ad9fe to 0d0e0f0 Compare November 18, 2026 16:25
@k-kostin
k-kostin force-pushed the codex/cancel-thumbnail-requests branch from 0d0e0f0 to 58eba49 Compare November 23, 2026 14:51
@dhh

dhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Superseded by #219 (shipped in v0.7.3), which cancels running thumbnailer and pdftoppm process groups when requests are discarded without recording failure markers.

@dhh dhh closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants