Skip to content

Feat: Add Viewport Renderer#1464

Open
Azraeel wants to merge 1 commit into
Azgaar:masterfrom
Azraeel:viewport-renderer
Open

Feat: Add Viewport Renderer#1464
Azraeel wants to merge 1 commit into
Azgaar:masterfrom
Azraeel:viewport-renderer

Conversation

@Azraeel
Copy link
Copy Markdown

@Azraeel Azraeel commented Jun 3, 2026

This PR improves performance on large, dense maps by virtualizing the most expensive SVG layers. Burg labels/icons and routes now render through a viewport-aware renderer, so the live DOM stays much smaller during pan and zoom while preserving normal SVG crispness.

What Changed

  • Added a ViewportRenderer for burg labels, burg icons, anchors, and routes.
  • Renders only visible or high-priority items at normal map scale, with level-of-detail behavior while zooming.
  • Keeps editor and overview workflows working by force-rendering selected burgs/routes when needed.
  • Ensures exported SVG/PNG clones still include the full burg and route layers.
  • Optimized scale bar redraws to avoid rebuilding its SVG content on every zoom frame.
  • Fixed a legacy map migration crash when old saves have burg data but no burg icon groups.

Why

Large maps with many cities, labels, nations, and routes were becoming sluggish because pan/zoom had to move and repaint thousands of live SVG nodes. This keeps the interactive map lightweight while keeping exports and editing behavior complete.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 0a22038
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6a20144394ab29000884e03d
😎 Deploy Preview https://deploy-preview-1464--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Azraeel Azraeel changed the title Add Viewport Renderer Feat: Add Viewport Renderer Jun 3, 2026
@Azraeel
Copy link
Copy Markdown
Author

Azraeel commented Jun 3, 2026

This helps significantly on 100k point maps with lots of burgs, rivers, and labels.
Kills most of the oppressive UI Lag on huge maps too.

Performance Notes

Measured against origin/master on a dense generated map:

Metric master viewport-renderer Change
Burg label DOM nodes 1,202 324 -73.0%
Burg icon DOM nodes 1,202 324 -73.0%
Route path DOM nodes 1,072 463 -56.8%
Exported burg labels 1,202 1,202 full export preserved
Exported burg icons 1,202 1,202 full export preserved
Exported routes 1,072 1,072 full export preserved

Chrome trace over scripted pan/zoom sequence:

Trace work master viewport-renderer Change
Layout 292.43ms 192.50ms -34.2%
PrePaint 58.24ms 32.79ms -43.7%
Paint 124.06ms 106.18ms -14.4%
Layout + PrePaint + Paint 474.73ms 331.47ms -30.2%

@Azgaar Azgaar self-requested a review June 3, 2026 12:16
@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Jun 3, 2026

Hello and thanks for the contribution! I like the concept, but the code is really messy and unpolished. If we rethink it into a minimal system, then we can try to go with it.

@Azraeel
Copy link
Copy Markdown
Author

Azraeel commented Jun 3, 2026

sure i can do some significant polish !

@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Jun 3, 2026

I mean we need to rethink the concept. E.g. for burg labels/icon we already have a system to hide them based on zoom level, so we can omit them from DOM as well. Can do the same for routes. You solution is overcomplicated, like on zoom 1 I get 812 burgs of group town generated, all of them as hidden on that zoom, but I see 188 of them in DOM. I would prefer a ViewportRenderer to completely replace the old invokeActiveZooming function and zoomRaf concept to actually remove/add elements to DOM rather then just hide/show on the parent level.

There is also a dependency on labels positions that we currently keep in svg (not in pack data), so #1313 should be completed first to not lose the data on dom recreation.

@Azraeel
Copy link
Copy Markdown
Author

Azraeel commented Jun 3, 2026

ahhh thats makes sense!
I can work on that if we could communicate more deeply on the topic!

@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Jun 3, 2026

Yes, would need to start with a proper planning, PRD creation, then architecture scheme and only then to development.

@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Jun 3, 2026

Drafted an AI PRD for the change:
viewport_rendering_prd_Version3.md

It still requires a lot of thinking as it can be done more elegantly, but the idea is clear.

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.

2 participants