Repository navigation
refactor(examples): drop the source caches MosaicLayer no longer needs - #842
Merged
Merged
Conversation
naip-mosaic and vrt-mosaic turned MosaicLayer's cache off and kept their own cache of opened sources, because each cached item used to keep its whole COGLayer. Since #839, an item out of view keeps only its opened source in MosaicLayer's cache, so both pass COGSource.open to getSource. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
commented
Nov 5, 2026
Comment on lines
+387
to
+390
| // MosaicLayer keeps each opened source in its cache, so an item that | ||
| // comes back into view isn't opened again | ||
| getSource: (item, options) => | ||
| COGSource.open(item.assets.image.href, { ...options, epsgResolver }), |
Member
Author
There was a problem hiding this comment.
Just to clarify; how big is the MosaicLayer source cache? Is this set by maxCacheSize?
Member
Author
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Yes. MosaicLayer passes maxCacheSize to its inner TileLayer, whose tile cache has one entry per item. Since #839, each entry keeps only the item's opened source.
- Default: with
maxCacheSizeunset, deck.gl caps the cache at five times the items in view, recomputed as the view changes. In my checks, that was 180 sources for naip-mosaic at zoom 11, with 36 items in view. - Eviction: deck.gl trims the cache only when a new item is added, and it drops items out of view, oldest-opened first. It doesn't move an item to the back of the cache when it's used again, so this is first-in, first-out rather than least recently used. Each dropped item gets
onSourceUnload. maxCacheByteSizedoesn't bound it yet (MosaicLayer's maxCacheByteSize leaves its cache unbounded #803).
The comment said that a returning item "isn't opened again", which only holds while the item is still cached. 4b3ee88 says how many sources the cache keeps.
🤖 Written by Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
naip-mosaic and vrt-mosaic turned MosaicLayer's cache off (
maxCacheSize: 0) and kept their own cache of opened sources. Until #839, each item in MosaicLayer's cache kept its whole COGLayer and that layer's textures, so caching items there was expensive. Now an item out of view keeps only its opened source. So both examples passCOGSource.openstraight togetSource, and rely on MosaicLayer's cache.Changes
maxCacheSize: 0. naip-mosaic still passes itsepsgResolvertoCOGSource.open.One difference: the examples' caches kept every source they had ever opened, forever. By default, MosaicLayer's cache holds up to five times the items in view. So after a long trip, an item may have left the cache and must be opened again, though its header bytes are usually still in the range reader's cache.
Checks
In Chrome, panning through several areas and back:
Neither example logged errors. The workspace typecheck, Biome, and both examples'
vite buildpass.Ref #803
🤖 Written by Claude Code