You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vector Rendering First-Frame Performance Plan 2/3 - #96
Phase 2 replaces first-use GEOS triangulation with earcut and prepares missing
fill meshes in the background, so Automatic rendering can present a GDI frame
without blocking on mesh generation.
The renderer uses at most four polygon workers, keeps GEOS as the fallback, and
publishes results only on the control thread after validating layer ID, scene
identity, and generation token. Pending work is discarded after replacement or
invalidation.
The ISC-licensed earcut-hpp dependency is added through vcpkg. Project memory
now records the dependency wiring and background cache lifecycle.
Validation: Debug x64 MSBuild completed with 0 warnings; all 493 non-interactive
CTest cases passed. The Release real-dataset lazy-fill benchmark completed 2,470
polygons in 93.8 ms.
- use earcut with bounded parallel triangulation and a GEOS fallback
- publish immutable scene results on the control thread and discard stale work
- cover pending, ready, failed, replaced, and cancelled mesh states
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved defects can terminate the process during worker startup, overwrite unrelated cached layers, reject valid triangulations, and prevent mesh publication after control reactivation.
This PR implements Phase 2 of the first-frame performance plan: faster polygon triangulation in Core and background fill-mesh preparation in ActiveX, allowing Automatic rendering to use GDI while meshes are pending.
Changes:
Adds earcut as the triangulation fast path, retaining GEOS as fallback.
Introduces bounded background workers, owner-thread publication, and cancellation of stale mesh work.
Updates regression tests, performance documentation, and project memory.
Project builds and test suites were not run during this review.
The reason will be displayed to describe this comment to others. Learn more.
Review completed against the repository's reviewing-pull-requests skill and the development base. I inspected the changed implementation, tests, dependency wiring, documentation, and current review threads. I found no additional distinct findings to post; the four existing unresolved inline findings already cover the issues identified in this pass. CI was still in progress at the time of review. No approval or change-request decision has been submitted.
pmeems
changed the title
MapWinGIS6 – Vector Rendering First-Frame Performance Plan
Vector Rendering First-Frame Performance Plan
Nov 25, 2026
pmeems
changed the title
Vector Rendering First-Frame Performance Plan
Vector Rendering First-Frame Performance Plan 2/3
Nov 25, 2026
The reason will be displayed to describe this comment to others. Learn more.
Automated review against the repository's review skill and the development base. Final decision is with the human reviewer. The four existing unresolved inline findings (worker-startup std::terminate, reactivation of preparation/dispatch, cache erase-iterator overwrite, shoelace area cancellation in projected coordinates) still apply and were not duplicated here.
CI — needs attention before merge:
Major | High:build-debug-x64 (legacy MSBuild leg) fails at this head SHA (198cdae): the build and parity steps succeed, but the Test step fails after ~24 s. Every other leg — including Release MSBuild (build-release-x64) and the CMake VS Debug x64 leg, which run the same test suites — passes, and development is green, so this is very likely caused by this PR. The PR body states all 493 non-interactive tests pass; the failing Debug x64 MSBuild test run contradicts that and should be investigated (I could not access the job log to identify the failing test).
Minor (infrastructure):cmake-vs-release-x64 / build is stuck: its Configure CMake step has been "in progress" for 8+ hours despite the 180-minute job timeout. This looks like a hung runner rather than a code problem — cancel and re-run it so the merge gate can clear.
- make worker teardown and cancellation exception-safe
- restart preparation after control reactivation
- stabilize earcut mesh validation and renderer regression tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved renderer recovery and job-handling defects can leave layers stuck on GDI or meshes permanently pending, while triangulation tolerances can accept incorrect polygon fills.
If completed.push_back fails to allocate, this handler drops the result after its active token and cancellation flag have already been erased. The owner-thread cache remains Pending, but there is no remaining job or completion to transition it, and future preparation calls skip the same scene. Preserve a failure outcome that can be delivered without another allocation, or provide an owner-thread recovery path that resets the matching Pending entry.
Failed completion posts are never retried while idle
If posting the last or only completion fails, the result remains queued but no retry is scheduled: the worker waits for another job, and retrying only on later completions cannot help an idle control. Once the GDI layer bitmap is cached, subsequent paints bypass VectorLayerRenderer::Draw, so they do not publish the result either. Schedule an independent retry wake or owner-thread timer while unpublished results remain, and cover a single completion whose first post fails.
Area tolerance accepts incorrect self-intersecting meshes
For the self-intersecting ring (0,0), (2e-6,2e-6), (2e-6,0), (0,1e-6), this tolerance accepts earcut's mesh area of 2e-12 against an expected 1e-12, allowing an incorrect fill. The clipping behavior was checked in v3.2.4 and matches the linked default-branch code. Use a scale-aware error bound for both triangulation paths, including the GEOS return at line 434, and add a scaled self-intersection regression.
- continue background preparation while OpenGL retries initialization
- commit pending state only after cancellation and queue bookkeeping succeeds
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved findings can strand pending meshes, leave completed meshes unpublished, block the control thread with duplicate preparation, and allow incorrect polygon fills to bypass fallback.
No open issues 🎉
4 previously missed issues
In code that hasn't changed since last review
Completion allocation failure can leave cache entries permanently pending
If completed.push_back throws, the job's active token and cancellation flag have already been erased, and the only result is dropped. The cache entry remains Pending with no work to resolve it, so subsequent preparation skips the layer permanently even after memory pressure subsides. Allocate durable completion storage before enqueueing the job, or retain an allocation-free failure signal that lets the owner thread leave Pending.
If the last outstanding completion's wake fails, the worker waits for new jobs and never retries it. Cached GDI paints bypass publication, leaving ready meshes unpublished even after the message queue recovers. Retry while completions remain, for example with the existing dispatch-window retry timer, and stop retries when results are drained or the control closes.
OpenGL paint synchronously regenerates meshes already being prepared
An explicit-OpenGL control paint during background preparation cancels a matching Pending entry and regenerates its meshes synchronously. This blocks the control thread and can compute in-flight polygons twice, since both load paths already queue background work. Preserve entries backed by background work and use GDI until publication; keep synchronous lazy preparation for entries without background work.
Absolute area tolerance accepts invalid exterior-only meshes
The 1.0 floor accepts an exterior-only mesh of area 1.6e-11 for a [0,4e-6]² square with an outside [10e-6,11e-6]² ring, whose expected area is 1.5e-11. Earcut's upstream default branch skips unbridgeable rings, so this tolerance lets an incorrect OpenGL fill bypass fallback. Remove the absolute floor and add a scaled invalid-ring regression.
- reserve completion storage before accepting jobs
- retry failed completion wakes through the dispatch window timer
- preserve pending background work during explicit OpenGL draws
- reject invalid tiny-scale polygon fills before fallback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved completion-handling defects can terminate the host on allocation failure or leave rendering results unpublished when the cross-thread retry timer fails.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A failed wake-post retry loop can survive cancellation and block jobs after reactivation, and constructor allocation failures can leak the GEOS context.
- stop failed completion wakes when a layer is cancelled or replaced
- retain the GEOS context in RAII during validation setup
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate triangulation that can violate even-odd fill behavior and a holed-polygon path that bypasses required GDAL initialization.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Hole validation performs quadratic GEOS relation checks against all earlier holes, creating a severe single-polygon performance bottleneck for valid polygons with many interior rings.
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
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.
Phase 2 replaces first-use GEOS triangulation with earcut and prepares missing
fill meshes in the background, so Automatic rendering can present a GDI frame
without blocking on mesh generation.
The renderer uses at most four polygon workers, keeps GEOS as the fallback, and
publishes results only on the control thread after validating layer ID, scene
identity, and generation token. Pending work is discarded after replacement or
invalidation.
The ISC-licensed
earcut-hppdependency is added through vcpkg. Project memorynow records the dependency wiring and background cache lifecycle.
Validation: Debug x64 MSBuild completed with 0 warnings; all 493 non-interactive
CTest cases passed. The Release real-dataset lazy-fill benchmark completed 2,470
polygons in 93.8 ms.