Repository navigation
fix(layout): the Layout view no longer waits for legend pictures, and an export's waits are complete and cancellable (#2008) - #2279
Conversation
… an export's waits are complete and cancellable (opengeos#2008) Part of opengeos#2008 (section 3, first finding). The interactive page (render_pending) never waits for WMS/WMTS legend pictures: it reports which frames and legends were drawn without content still on its way (PagePending), and the Layout view redraws once those legend pictures have all landed, on the desktop as well as in the browser, not on every unrelated fetch. Exports (render, render_drawing, layout_svg, the raster export) still wait: one legend budget per page, 30 s, stopping at once on Cancel with the established cancelled error. An export that drew a legend whose picture was still on its way is refused rather than written without it, even if the picture lands afterwards. A legend wholly off the page is neither waited for nor counted, decided by one test shared by the page's drawing and the redraw gate.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| // for) shows none of its pictures: nothing to wait for or to be missing. | ||
| let on_canvas = element.is_some() || on_page(layout, e); | ||
| if wait_legends && on_canvas { | ||
| wait_for_tile_legends(map, scale, exclude, legend_deadline())?; |
There was a problem hiding this comment.
Bug (confidence: high on the behaviour, impact depends on timing): legend_deadline() runs for every on-canvas legend, even when none of its pictures is pending. So the export's 30 s clock starts at the first legend drawn, not at the first wait. The comment on legend_deadline says it is "started by the first legend that waits", so this contradicts the intent.
Failure scenario: legend A's picture is ready and starts the clock at t=0. Frame B then spends 30 s or more on its tiles. Legend B's WMS picture is only requested at t=35 s. wait_for_tile_legends checks now < deadline first, so it never requests or waits for B's picture. B is drawn without it and the export is refused, though a fresh 30 s budget would have covered it.
Suggested fix: only start the clock when a picture is actually pending.
| wait_for_tile_legends(map, scale, exclude, legend_deadline())?; | |
| if wait_legends && on_canvas && tile_legends_pending(map, scale, exclude) { | |
| wait_for_tile_legends(map, scale, exclude, legend_deadline())?; | |
| } |
A regression test should assert that LEGEND_BUDGET stays Some(None) after a legend whose picture is ready has been drawn in an export.
There was a problem hiding this comment.
Fixed in 9db7345: the clock now starts only when a picture is actually pending, with a test that a legend whose picture is ready leaves it unstarted and that a later legend still gets the whole wait.
| legend(&mut pm, r, map, (title, *columns), drawn, opts, ppp); | ||
| // Whether a picture was still on its way when the rows were made: the very lookup | ||
| // that drew the legend, not an earlier one a retry or an eviction could outdate. | ||
| let missing = legend_missing(&mut pm, r, map, (title, *columns), drawn, opts, ppp) && on_canvas; |
There was a problem hiding this comment.
Silent omission (confidence: medium; pre-existing, but this PR states the opposite for exports): the refusal relies on legend_missing, which relies on tile_legend. That function (around line 2162, not in this diff) handles State::Failed (a 404 or a network error) and a picture larger than MAX_LEGEND_SIDE with _ => {}, the same as "not yet loaded". Only State::Pending sets missing. So an export whose WMS or WMTS legend fails is written without that picture, with no notice and no refusal.
This contradicts the PR description ("An export that drew a legend without one of its pictures is refused ... rather than written incomplete"). It also breaks the "Never silent" rule in AGENTS.md, which requires a notice wherever data is dropped.
Either refuse the export for a failed or oversized picture, as for a pending one, or report it through ToolResult::messages / Session::notify with a count. If the omission is intended, the PR description and docs/user-guide/layouts.md should say that a failed picture is dropped silently.
There was a problem hiding this comment.
Right that a failed or oversized picture is left out of an export without a notice, but that is the existing behaviour of tile_legend (#1168) and a different finding from the waits this PR fixes: it needs its own notice path, so it is out of scope here and a follow-up candidate. The user guide already says such a picture is left out; 9db7345 corrects this PR's wording (docs, comment and description) to say that only a picture still on its way stops an export. (reviewed at 43605eb)
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Already raised: none. There were no earlier review threads on this PR. Confidence: both findings were verified by reading the code. I did not run the tests or the wasm build, since I have no shell here. Change sizeCompared: the whole PR against main (merge base d30f427 to PR head 43605eb). No trees were truncated.
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
…its way, and the docs say only that stops an export (opengeos#2008) An export's 30 s legend budget started at the first on-canvas legend drawn, even one whose picture was ready, so a later legend whose picture was first asked for after 30 s was never waited for and the export was refused. The wait, and so the clock, now starts only when a picture is pending. The docs and the finish_legends comment say that a legend picture still on its way stops an export; a picture that failed or is too large is left out, as the docs already said.
Code reviewI reviewed the full diff against the base-branch AGENTS.md, both prior threads, and the code they touch. I did not run tests, clippy, or the wasm build, since I had no execution tool. CI and the author's test runs are the check for those. Bugs: No new defects found at medium or higher confidence.
Security: None found. No new input paths. Legend addresses still go through Performance: Low. Quality (nits, for the release quality pass, not posted inline):
AGENTS.md:
Earlier concerns left alone: 2. One (clock start) is fixed in 9db7345 and verified above. The other (silent omission) is covered in AGENTS.md above. Change sizeCompared: the whole PR against main (merge base d30f427 to PR head 9db7345).
|
Summary
The Layout view slept on the interface's thread, up to 30 s, while a WMS or WMTS legend picture was on its way, so the window froze on a slow service. The same wait in an export had no way out: Cancel was not looked at, and a picture still missing when the wait ran out was drawn without, leaving a file that looked complete.
PagePending { frames, legends }); the page is drawn again once its legend pictures have all landed, not on every fetch (the rule fix(layout): the browser's layout page is drawn again once its legend pictures land, not on every fetch #1177 added for the browser, now on the desktop as well).on_page, in millimetres) decides it for the page's drawing and for the redraw, so no resolution makes them disagree.Kind of change: any maintainer; no new command, parameter, saved field or dependency.
docs/user-guide/layouts.mddescribes the wait and the Cancel behaviour.Testing
On the head, run through a private build lane of my own (the shared one was held by another bundle's stopped build):
cargo xtask test-hygieneok,cargo fmt --checkok,cargo clippy --workspace --all-targets -- -D warningsok.cargo test --workspaceis not green on my machine: 2 tests fail, and both fail identically on a cleanorigin/main(d30f427e), with no change of mine involved:rustgis-datasource::tests::geopackage_provenance_skips_a_replaced_path(3 of 3 runs on clean main)rustgis-enginetests::session_log_export_inputs_exclude_output_reloads(2 of 2 runs on clean main)Both assert
i.path == path.display().to_string()in the input fingerprints feat(engine): record the RustGIS version and input file fingerprints in the Session log (#1998) #2253 added to the Session log. I don't know the cause and haven't tried to fix it here. Everything else incargo test --workspace --no-fail-fastpassed, including all 84 of the render crate'slayout::tests.cargo xtask layers: ok.project_schema --check: schema matches, 12 fixture projects open.pre-commit run --all-files: all hooks passed.RUSTFLAGS="-D warnings" cargo build --locked --target wasm32-unknown-unknown -p rustgis-web: ok.New tests (render): a page waits for its legends only until its deadline; an export shares one legend deadline across its calls; a legend whose picture is ready does not start the export's legend clock; an SVG export gives up on held legends at one deadline; an export drawn without a legend picture stays refused when the picture lands later; an off-page legend holds no export up; a legend says from the lookup that draws it whether a picture is missing; only an on-page legend is waited for by the redraw; the drawing and the redraw gate agree on a legend at the page's edge; cancelling a pending raster read returns no archive. UI: the desktop page waits for its legend, not for unrelated fetches.
Real
ui_shotruns of the Layout view with a legend picture held back by a local test server (first paint after the legend was requested): 30.1 s on the base, 0.03 s with this change. See below.CI on this head (9db7345): every check passes, including the full Linux
cargo testjob and the wasm build, so the two tests above pass on Linux.Reviewed with review-loop: 5 rounds, 5 findings fixed, 1 declined.
UI evidence
The page after the legend picture has landed, from a real
ui_shotof the Layout view (a WMS legend held back by a local server for the "Delayed legend" layer). The screenshots were taken on an earlier commit of this branch; the Layout view's behaviour they show is unchanged since.Before (first paint after the legend was requested took 30.1 s; after the picture arrived the page never showed it, because the wait had already given up and nothing redrew it):
After (first paint 0.03 s; the page is drawn again once the picture lands, and shows it):
Related issue
Part of #2008 (section 3, its first finding only): claim. Not closing it: the rest of the audit stays open.
Reaches
layout.export; they get the refusal message, and Cancel where they have it.