fix: evaluate zoom-dependent symbol sizes at the drawn zoom - #8175
Open
mondsichtung wants to merge 2 commits into
Open
fix: evaluate zoom-dependent symbol sizes at the drawn zoom#8175mondsichtung wants to merge 2 commits into
mondsichtung wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8175 +/- ##
==========================================
+ Coverage 93.92% 93.95% +0.03%
==========================================
Files 290 290
Lines 24916 24924 +8
Branches 6575 6576 +1
==========================================
+ Hits 23402 23417 +15
+ Misses 1514 1507 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
I think I understand the fix, but it would be helpful to show a short design document to better explain this change. |
Contributor
Author
|
Refactored in 1632f31, design document was added to the initial post |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix labels briefly drawn too large when zooming out fast with a zoom-dependent
text-size/icon-sizeOn a fast zoom-out, tiles kept on screen from the deeper zoom draw labels at the size baked for their own zoom:
camerasizes were clamped into the two stops around the tile's zoom, a restriction onlycompositesizes need (their per-feature sizes are baked into vertex data).camerasizes now keep the whole stop table (plain arrays, still worker-transferable) and are evaluated at the drawn zoom, capped at the size the tile's collision boxes were built from.composite,constant, andsourceare unchanged.Design: evaluate camera symbol sizes at the drawn zoom
Symptom
Zoom out quickly on a style where
text-sizeoricon-sizegrows with zoom, and labels flash too large for about half a second. The tiles kept on screen from the deeper zoom draw their labels at the size for their own zoom, not the camera's.Background
A symbol bucket classifies its size property into one of four kinds. The data is baked in the worker, so it must be plain transferable values, not the expression itself:
constantsourcecameracompositeAt draw time,
evaluateSizeForZoomturns the camera zoom into shader uniforms.Cause
For
composite, clamping the camera zoom into the tile's two stops is forced: each feature only carries its size at those two zooms, so blending between them is all the renderer can do.camerahas no per-feature data, but took the same clamp anyway, for symmetry (per an old comment). So a tile parsed past the function's last stop draws one fixed size at every camera zoom. That is the flash.Fix
For
camera, bake the size at every zoom stop instead of two (still plain arrays). At draw time, interpolate within the segment containing the drawn zoom. This reproduces the size expression exactly, for interpolate and step alike. One wrinkle: a step's first stop is-Infinity, which cannot be evaluated at, so its base value is sampled just below the second stop.composite,constant, andsourceare unchanged.Why the result is capped at layoutSize
Collision boxes are baked from the size at tileZoom + 1. If a retained tile drew labels larger than that, they could overlap their neighbours, trading one artifact for another. So the drawn size is capped at that baked size (
layoutSize).The cap never binds inside a tile's own zoom range, so steady state is unchanged. It does not bind on the zoom-out this fixes either, where the correct size is the smaller one. The one case it leaves as-is (today's behaviour, not a regression): zooming in on a retained parent tile still draws labels slightly small until the children arrive. Fixing that means scaling the collision boxes, a separate change to the placement path.
Launch Checklist
*.bench.ts), post before/after results ofnpm run bench(the compare workflow is intest/bench/README.md).CHANGELOG.mdunder the## mainsection.Generated-By: Claude Fable 5 (high)