Skip to content

Vector Rendering First-Frame Performance Plan 3/3 - #97

Merged
pmeems merged 3 commits into
developmentfrom
phase-3-remaining-costs-docs
Nov 26, 2026
Merged

pmeems merged 3 commits into
developmentfrom
phase-3-remaining-costs-docs

Conversation

@pmeems

@pmeems pmeems commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

Finish the remaining first-frame rendering work without moving expensive setup into the next paint or blocking the test host during dataset reads.

Context

This is Phase 3 of the first-frame performance plan, built on GDI-first Automatic frames and background earcut mesh preparation. The real-dataset Release path measured 93.4 ms load + 21.6 ms first paint synchronously and 194.4 ms + 20.4 ms asynchronously.

Key design decisions

  • Warm the OpenGL context, staging buffer, and FBO when all background meshes are published, before invalidating the GDI frame.
  • Use BeginLoadVectorDataset and completion events for interactive host Open and drag-and-drop loads.
  • Keep pixel-level vertex reduction and OGR batch/Arrow reads deferred because current measurements meet the target without adding viewport caches or driver-specific semantics.
  • Update .ai/memory/lessons/lessons.md with the verified first-consumer and Debug/Release lessons.

Dependencies

No new dependencies. Earcut and the existing asynchronous COM loading contract are reused.

Validation

  • CMake Debug x64 and Release x64 builds
  • 507/507 non-interactive Debug CTest cases
  • Automated ActiveX host checks
  • Real-dataset Release rendering baselines; no code-level Level 4 warnings

- Warm OpenGL target resources before the backend-switch repaint
- Load interactive host datasets through the asynchronous COM path
- Record release measurements, documentation, and rendering lessons

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rendering races can still stall the first visible frame, cancellation can leave native load slots retained, and first-frame timing may measure a later cached redraw.

4 open issues
What changed in this PR

This PR implements Phase 3 of the vector-rendering performance plan: preparing OpenGL targets before the backend-switch repaint and moving interactive dataset reads off the C# host’s UI thread.

Changes:

  • Extracts reusable OpenGL target initialization and invokes it when background meshes are published.
  • Adds asynchronous Open/drop loading and updates the host’s automated checks.
  • Adds warm-up coverage and documents measurements, lessons, and deferred optimizations.

Builds and tests were not run during this review.

File Description
tests/​MapWinGIS.ActiveX.Tests/​VectorLayerRendererTests.cpp Adds a target warm-up test.
tests/​MapWinGIS.ActiveX.Tests/​OpenGlVectorLayerRendererTestAccess.h Exposes warm-up state for assertions.
src/​MapWinGIS.ActiveX/​VectorLayerRenderer.h Gates warm-up on backend preference and mesh readiness.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.h Declares warm-up and shared target initialization.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.cpp Shares target setup between warm-up and drawing.
src/​MapWinGIS.ActiveX/​MapWinGISControl.cpp Warms the target during mesh publication.
samples/​CSharp/​ActiveXTestHost/​VectorLoadClient.cs Adds asynchronous COM loading and result retrieval.
samples/​CSharp/​ActiveXTestHost/​README.md Documents async loading and backend transitions.
samples/​CSharp/​ActiveXTestHost/​MainForm.cs Routes interactive loads through the async client.
docs/​TESTING.md Records Phase 3 behavior and performance measurements.
docs/​ARCHITECTURE.md Describes target preparation before repaint.
.github/​plans/​Vector-Rendering-First-Frame-Performance.md Marks Phase 3 complete and records limitations.
.ai/​memory/​lessons/​lessons.md Documents first-consumer costs and build-specific measurements.

Review effort: Balanced

@Julian-MW Julian-MW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review. Final decision is with the human reviewer.

Scope reviewed: OpenGL target warm-up extraction (InitializeTarget/WarmUp), the publish-time warm-up in CMapWinGISControl::DispatchFillMeshPreparation, the new async vector-load client and host changes, tests, and docs/memory updates.

The refactor of the draw-path initialization into InitializeTarget is faithful to the previous code, the C# COM client matches the IDL (IID, DispIds 18–20, events IID/DispId 2), and threading assumptions check out (publish and warm-up run on the owner thread; the completion callback runs before sink notification, so EndLoadVectorDataset polling is safe).

Five findings posted as line comments (3 Minor, 2 Suggestion), none blocking. Not re-posted because the existing Copilot review already covers them: first-frame measurement possibly capturing a cached repaint, cancellation letting E_PENDING escape before EndLoadVectorDataset releases the native slot, draw-side mesh publication bypassing warm-up, and warm-up possibly delaying the first visible frame.

@pmeems pmeems changed the title MapWinGIS6 – Vector Rendering First-Frame Performance Plan Vector Rendering First-Frame Performance Plan 3/3 Nov 26, 2026
- Defer fill-mesh publication and OpenGL warm-up until the first frame of a new layer set is presented
- Leave owner-dispatched fill-mesh publication to the completion handler instead of Draw
- Ignore unsized OpenGL warm-up targets without recording a failure reason
- Keep warm-up attempts from consuming the draw retry back-off
- Wait for EndLoadVectorDataset after cancellation so the native load slot is released
- Require the observed completion event and measure the first frame inside it in the test host
- Return interactive load failures instead of throwing from async-void callers
- Add tests and update the docs, plan, and lessons memory

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The scope guard acknowledges failed draws as presented, clearing the pending-frame flag and allowing OpenGL allocation before the first successful GDI frame.

1 open issue
4 resolved since last review

Review effort: Balanced

@pmeems
pmeems enabled auto-merge (squash) November 26, 2026 17:16
- Clear the pending layer frame only after a successful, drawable, client-sized draw
- Keep fill-mesh publication deferred after failed or undrawable draws
- Add a regression test for an undrawable frame

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Clear can remove a loaded layer before its list entry is added, leaving a stale row that only triggers a metadata warning and fails when zoomed to.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Prevent stale layer rows after clearing during load

samples/​CSharp/​ActiveXTestHost/​MainForm.cs:594

Severity: Minor | Confidence: High

Issue: Clear remains enabled while the load is awaited and can remove a committed layer before the continuation adds its list entry. Impact: The stored load result still reports success, so this line inserts a stale row; the metadata check only warns, and zooming to that row fails. Fix: Verify that the returned layer still exists before adding its row, or block Clear for the duration of the load batch.

1 resolved since last review

Review effort: Balanced

@pmeems
pmeems merged commit e9b5f94 into development Nov 26, 2026
18 checks passed
@pmeems
pmeems deleted the phase-3-remaining-costs-docs branch November 26, 2026 18:43
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.

3 participants