Skip to content

fix: cache ocean embellishments to reduce map panning lag - #1967

Merged
Azgaar merged 1 commit into
Azgaar:masterfrom
barrulus:fix/ocean-embellishment-performance
Oct 16, 2026
Merged

Azgaar merged 1 commit into
Azgaar:masterfrom
barrulus:fix/ocean-embellishment-performance

Conversation

@barrulus

Copy link
Copy Markdown
Collaborator

Description

Ocean bands and waves repeatedly rasterize complex SVG masks during map movement, causing substantial panning lag in presets such as Atlas. Cache these layers as viewport-sized images so nearby pans can reuse the rendered artwork.

The cache refreshes for zoom, viewport coverage, coastline edits and rendering-quality changes. Original vectors remain available as a fallback and are restored in save/export clones, so .map files and SVG exports retain their original paths and masks. No dependencies or save-format changes.

Refs #1966. This addresses ocean embellishments; Frostbite's separate settlement-icon filter cost remains.

Performance

Average animation-frame interval during the same 30-step pan (lower is better):

Preset Original vectors Cached
Ink 66.1 ms 22.2 ms
Ancient 105.4 ms 25.4 ms
Cinderwood 160.0 ms 30.5 ms
Atlas 113.8 ms 29.6 ms
Frostbite 163.5 ms 123.0 ms
Gloom 53.0 ms 27.9 ms

Measured with Chromium 155 / SwiftShader, seed 1966, 1600×900 viewport, political layers, Balance quality, DPR 1 and 3× zoom. Camera transforms were asserted before and after each drag. These software-rendering measurements show the relative improvement, not expected timings on a particular GPU.

Validation

  • Build, TypeScript and repository-wide Biome checks passed.
  • 59 focused tests passed across ocean caching, ocean rendering, coastal waves and exports.
  • Screenshots matched pixel-for-pixel within the map comparison area for all six presets above.
  • Browser checks covered DPR 2 and zoom changes, coastline invalidation, disabling effects, .map save/reload, SVG export and the PNG export pipeline.
  • Unit tests cover cache reuse, vector restoration, stale async completion, failure fallback and blob URL release.
  • Manually reviewed in the local test server.

Raster allocations are capped at approximately 16 megapixels per ocean layer. Very large or high-DPI views may use reduced on-screen resolution; an existing image can briefly scale while its replacement loads. Native vector saves and exports are unaffected.

@netlify

netlify Bot commented Oct 16, 2026

Copy link
Copy Markdown

✅ Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 59cba15
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6ad1e289018552527bc2a78e
😎 Deploy Preview https://deploy-preview-1967--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.

@barrulus barrulus self-assigned this Oct 16, 2026
@barrulus barrulus added theme: ui-editors UI / UX & Editors theme: labels-styling Labels & Styling labels Oct 16, 2026
@barrulus barrulus moved this from Backlog to In review in FMG dev board Oct 16, 2026
@barrulus
barrulus marked this pull request as ready for review October 16, 2026 08:41
@Azgaar
Azgaar self-requested a review October 16, 2026 10:28
@Azgaar

Azgaar commented Oct 16, 2026

Copy link
Copy Markdown
Owner

@barrulus, the solution is working fine, but I'm not sure I like how isolated it is. We may want to raster-render any layer (like we tried with reliefs), not just ocean bands. And this should be optional under performance settings.

So I would prefer a generic 'rasterization' select in performance settings. If it's yes, then we do this caching (rasterization can be more clear name) for what we support. The rasterization module can be much more universal and work on pretty much any layer, not just on ocean bands.

@Azgaar

Azgaar commented Oct 16, 2026

Copy link
Copy Markdown
Owner

This would also close #1352 if we add Relief. But we need to think how to make the solution clean.

@barrulus, let's me know if you would rather merge as it's now and leave a major rework for later.

@barrulus

Copy link
Copy Markdown
Collaborator Author

This would also close #1352 if we add Relief. But we need to think how to make the solution clean.

@barrulus, let's me know if you would rather merge as it's now and leave a major rework for later.

I think merge as is now, using the same mechanism to overall improve all relief work is a great idea, but it is a larger piece of work, this is a short win that will benefit people today

@Azgaar

Azgaar commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Ok, let's get back to it later. We have a Draft open for Raster layers.

@Azgaar
Azgaar merged commit bae507c into Azgaar:master Oct 16, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in FMG dev board Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme: labels-styling Labels & Styling theme: ui-editors UI / UX & Editors

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants