Skip to content

fix(layout): the browser's layout page is drawn again once its legend pictures land, not on every fetch - #1177

Merged
pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:fix/legend-redraw-on-land
Oct 30, 2026
Merged

pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:fix/legend-redraw-on-land

Conversation

@pick2510

@pick2510 pick2510 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1168, from its review (it merged before these went in):

  • The browser's layout page is drawn again once its legend pictures land, not on every fetch. While a WMS or WMTS legend picture was on its way, any fetch landing (the map's own tiles included) bumped the tile cache's generation and redrew the whole page. Now a generation change redraws it only once legends_pending says the pictures are in (a cache lookup per legend, only while one is pending).
  • The legend wait reads as render_complete's does: one runtime cfg! guard on the loop instead of a #[cfg] pair with an early return. Same behaviour: natively it waits up to half a minute for the legend's own pictures; in the browser it doesn't wait.

Tests

Summary by CodeRabbit

  • Bug Fixes
    • Layouts now wait for pending legend images before marking legend rendering complete, avoiding premature redraws while tiles are still loading.
    • On web, legend rendering no longer blocks while waiting for images. On desktop, it continues to wait synchronously.

…es land, not on every fetch

(cherry picked from commit aa32bcb30b3ffe4cd539e6262a8e0b9cafdb1569)
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4685bb73-18b2-4e4d-8f4b-bb44aa0dc256
Commits

Reviewing files that changed from the base of the PR and between bd9cb7c and bd3bf58.

Files selected for processing: 2
  • crates/render/src/layout.rs
  • crates/ui-egui/src/layoutview.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The layout page now requires both a changed tile-cache generation and no pending legends before treating rendering as complete. The wait loop for pending legend pictures runs on native targets and is skipped on wasm32.

Changes: Legend rendering

Layer / File(s) Summary
Legend completion and platform wait behavior
crates/ui-egui/src/layoutview.rs, crates/render/src/layout.rs
The layout page treats rendering as complete only after the tile-cache generation changes and no legends remain pending. The wait loop for pending legends runs on native targets, with the existing 15 ms checks and 30-second limit, and is skipped on wasm32.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • opengeos/RustGIS#942 — This issue concerns WMS and WMTS legend-picture loading. This PR also changes how layout rendering responds to pending legend pictures, though it targets the layout page rather than the Layers pane.

Possibly related PRs

  • opengeos/RustGIS#1168 — Adds legend pictures to layout rendering and introduces the browser legend-loading flow that this PR adjusts.
  • opengeos/RustGIS#1009 — Adds the tile-layer legend data and image cache used by the layout legend-rendering flow.

Suggested reviewers: giswqs

Merge Risk: Minimal · up to bd3bf

The browser now defers legend redraw until pending pictures finish, while native waiting remains unchanged. No actionable merge-blocking issue was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: redraw the browser layout page when legend pictures arrive instead of on every fetch.
Description check Passed The description includes a detailed Summary, Testing results, and a related issue reference. It does not include UI evidence, but the required sections are mostly complete and the omission is non-crit…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes a detailed Summary, Testing results, and a related issue reference. It does not include UI evidence, but the required sections are mostly complete and the omission is non-critical.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the legends in the light,
Then waits on native screens through each short night.
The browser skips that waiting round,
While pending pictures keep their ground.
When all are done, the layout draws just right.

Comment @coderabbitai help to get the list of available commands.

Comment thread crates/render/src/layout.rs Resolved
Comment thread crates/ui-egui/src/layoutview.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no correctness bugs. The redraw trigger works: cache::generation() is bumped when fetches complete, and the wasm path is single-threaded, so the captured generation can't race with a landing. Native behaviour is unchanged, since legends_wait stays None there.

Bugs

  • None found.

Security

  • None found. No new input handling or external data paths.

Performance

  • legends_pending runs on every repaint (about 250 ms) while pictures are pending in the browser. Each run is a camera computation plus a cache lookup per legend, and it can trigger requests for pictures not yet asked for. Acceptable here. Confidence: high that it's harmless; low that it matters. (inline comment on layoutview.rs:589)

Quality

  • The wasm build now compiles std::thread::sleep and std::time::Duration unconditionally. They're unreachable on wasm because of the cfg! short-circuit, but the guard is now the only protection. Confidence: medium. (inline comment on layout.rs:1225)
  • On wasm, wait_for_tile_legends no longer calls tile_legends_pending, so it no longer issues the early picture requests. legend() makes the same tile_legend calls with the same scale and exclusions in the same render, so requests still go out in the same frame. Confidence: high that this is behaviour-neutral.
  • The landed decision isn't covered by any test. The PR says the native tests can't drive it. Pulling the decision into a small pure function would make it testable. Confidence: medium.

AGENTS.md

  • No unwrap/expect/panic, no unsafe, no new strings needing tl!, and no new dependencies.
  • The std::time/std::thread::sleep reference on wasm is the item above.
  • legends_pending is already reachable from ui-egui through the same path used at line 604, so layering is fine.
  • The change is a bug fix rather than a substantial visible change, so screenshots aren't required.

Change size

Compared: the whole PR against main (merge base 32bbcb2 to PR head bd3bf58).

Metric Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 288.0 KB
Size after 288.2 KB
Total size change +208 B
Path Before After Change
crates/ui-egui/src/layoutview.rs 154.1 KB 154.0 KB +196 B
crates/render/src/layout.rs 133.7 KB 133.7 KB +12 B

@pick2510
pick2510 enabled auto-merge (squash) October 30, 2026 12:03
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-1177/
Web app https://preview.rustgis.app/pr-1177/app/
Commit bd3bf58

GitHub Pages takes a minute or two to publish a new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant