2D map: keep the land picture on the graphics card in Firefox on a computer

The 2D map paints its land into an offscreen picture. In Firefox that picture was a software canvas
(willReadFrequently), because Firefox on Android garbled big paths on its graphics card (#43). Firefox on a computer
had it too, and a software canvas is sent to the card again on every frame, at a cost that grows with the picture:
the whole world at mid zoom, four screens of it zoomed in.

Only Firefox on Android keeps it now (softCanvas()). Measured in Firefox 159 on Windows (RTX 4090, full screen
2560x1440), 2D map, frames per second at zoom 0.6 / 1.1 / 1.6 / 3.2:
- big-network fixture, main: 56 / 37 / 34 / 26; with this change: 64 / 49 / 51 / 78;
- the 183-POP save, main: 32 / 25 / 25 / 22; with this change: 36 / 26 / 33 / 55.
(Measured with the change injected into main's page; the land picture is the same code on this branch.)

tests/world-layer-firefox.test.js: which browsers get the software canvas, and that the land is an ordinary one
elsewhere.
This commit is contained in:
Antoine 2026-11-04 20:59:05 +01:00
parent cdc7c6d1eb
commit b03bec267c
No known key found for this signature in database
GPG key ID: 728FF1CE15732B05
3 changed files with 41 additions and 1 deletions

View file

@ -15,6 +15,7 @@ All notable changes to this project are documented here. The project follows
- Zooming is smoother on big maps: while you zoom, cities and ships keep their picture and are only redrawn sharp once the zoom stops, instead of being repainted at every small step.
- The graphics card draws the coastlines with fewer points when you zoom out, where the extra detail was smaller than a pixel, so the map costs it a lot less work, which helps phones most.
- The map leaves far less memory behind it on every frame for the browser to clean up while you play.
- In Firefox on a computer, the 2D map is up to three times as fast when zoomed in: its land picture now stays on the graphics card instead of being sent to it again on every frame. Firefox on Android keeps the old way, which avoids its drawing glitches.
- Settings › Viewport info is now Diagnostic info: besides your screen's size, it shows how the map is drawn (by the graphics card or in 2D, and why) and how fast, ready to copy into a bug report.
## [2.9.1] — 2026-11-04