Repository navigation
fix(layers): sample decoded raster tile images for hover - #3963
Merged
Merged
Conversation
Signed-off-by: Igor Dykhta <igorDykhta@users.noreply.github.com>
lixun910
approved these changes
Nov 2, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, although tests were not run during review and native ImageBitmap decoding remains untested.
No open issues 🎉
What changed in this PR
Fixes raster-tile hover sampling for decoded PMTiles images by reading RGBA pixels through a canvas, while preserving raw/scientific band sampling.
Changes:
- Reads pixels lazily and caches results weakly per image, including unavailable or security-blocked readbacks.
- Adds regression coverage for the loader-to-hover flow, coordinate selection, opt-in behavior, caching, image replacement, transparency, and raw buffers.
Verification: NOT RUN during this review. Canvas readback is mocked in the added tests; native ImageBitmap decoding remains untested.
| File | Description |
|---|---|
| test/browser/layer-tests/raster-tile-layer-specs.js | Adds decoded-image hover and fallback regression tests. |
| src/layers/src/raster-tile/raster-tile-identify.ts | Adds lazy canvas readback and weak per-image pixel caching. |
Review effort: Balanced
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.
PMTiles returns decoded browser images, so enabled hover previously found no pixels despite a loaded tile. Read RGBA pixels lazily through a canvas and cache them weakly per immutable tile image. Raw/scientific bands are unchanged; unavailable or security-blocked readback stays unavailable.
Tests exercise the tile loader → viewport cache → hover path, coordinate selection, opt-in behavior, caching/replacement, transparent pixels, raw buffers and SecurityError. Canvas readback is mocked in the local Node suite; native ImageBitmap decoding has not been exercised.
Verification: PASS targeted Tape (387 assertions), changed-file ESLint/Prettier and diff whitespace. FAILED as expected against unchanged master (regression reproduction). PASS full
yarn agent:verifyon Node 24.21.0 (initial sandbox attempt failed because MCP test listeners could not bind localhost; rerun with test permissions passed). PASS independent read-only review; no actionable findings.Review: