Repository navigation
fix(deck.gl-geotiff): abort a stale GeoTIFF parse when the source changes - #770
Merged
kylebarron merged 2 commits intoOct 22, 2026
Merged
Conversation
COGLayer started a new parse on every `geotiff` change, but its one AbortController lived as long as the layer and was only aborted in finalizeState. An old parse that finished last overwrote the new GeoTIFF's state and called onGeoTIFFLoad with the old file. One that finished first cleared loadingMetadata while the new parse was still running. updateState now aborts the previous parse and gives each parse its own controller, and only a parse that wasn't aborted clears loadingMetadata. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…changes MultiCOGLayer had the same race as COGLayer. An old parse that finished last overwrote the new sources' state and called onGeoTIFFLoad with the old sources. One that finished first cleared loadingMetadata while the new parse was still running. This applies the same fix. The onError test now builds its layer with makeBareLayer, like COGLayer's version of that test, because updateState now reads this.state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
approved these changes
Oct 22, 2026
kylebarron
left a comment
Member
There was a problem hiding this comment.
Thanks! I'm thinking we may rework this for 0.10, but this is good for now.
Contributor
Author
|
Happy to learn more and help test, any clue when this will become a new release? |
Member
|
I published 0.9.0-beta.3, and I'd like to get 0.9 out tomorrow or Monday |
kylebarron
added a commit
that referenced
this pull request
Oct 26, 2026
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Stage 1 of the Sources design, which this PR adds as `dev-docs/specs/2026-10-22-sources-design.md`. COGLayer, MultiCOGLayer and ZarrLayer each load their metadata from `updateState` and store the result in `state`. deck.gl hands that state object to every newer instance of the layer, so a load started by an earlier render can land after a newer one. #770 fixed this for the two COG layers by hand; ZarrLayer still had it. Now `RasterTileLayer` runs these loads, mirroring deck.gl's own `shouldUpdateState`, `updateState` and `_update()`: - **`shouldLoadMetadata(params)`:** subclasses override it to return `true` when a prop their metadata depends on has changed. - **`loadMetadata(signal)`:** subclasses override it to load the metadata and store it in state. After its last `await`, it calls `signal.throwIfAborted()` before `setState` or callbacks. - **`_loadMetadata()`:** `RasterTileLayer.updateState` calls this protected method when `shouldLoadMetadata` returns `true`. It: - aborts the previous load; - sets and clears `loadingMetadata`; - raises only the latest load's errors through `onError`, prefixed with the layer's name, as in "Metadata loading failed in COGLayer: …"; - aborts the load in flight when the layer is removed. Because every instance shares one `state` object, `setState` from the instance that started a load lands where the newest instance reads. The three layers drop their own `updateState`, and type their state as `RasterTileLayer<…>["state"] & {…}`, as deck.gl's MVTLayer does with TileLayer's. Fixes: - **ZarrLayer:** changing `node` or `variable` while the previous store is still loading no longer lets the old load overwrite the new one or mark the layer loaded early. ZarrLayer also passes the signal to zarrita's `open`, so a replaced load stops reading. - **MultiCOGLayer:** - It now runs `super.updateState`, which its own `updateState` skipped. - A replaced load's errors no longer reach `onError`, even when they're thrown while building its tile grid. Metadata errors now name the layer: "loading GeoTIFF: …", "loading COG sources: …" and "loading Zarr metadata: …" become "Metadata loading failed in COGLayer: …", "… in MultiCOGLayer: …" and "… in ZarrLayer: …". `shouldLoadMetadata` and `loadMetadata` are new public methods on `RasterTileLayer` and its subclasses; nothing new is exported. Notes for authors of `RasterTileLayer` subclasses: - An override of `updateState` must call `super.updateState`, which starts the loads. - An override of `finalizeState` must call `super.finalizeState`, which aborts the load in flight. - `state.loadingMetadata` and `state.metadataAbortController` belong to the base layer, and the default `_isLoadingMetadata()` reads `state.loadingMetadata`. Tests: - The race tests use real fixtures: COG files for the two COG layers, and a GeoZarr store for ZarrLayer. - They fail if the base doesn't abort the previous load, or if any layer's `loadMetadata` skips `throwIfAborted()`. - The Zarr tests also fail if either `open` call drops the signal. - The base tests also check that a re-render whose `shouldLoadMetadata` returns `false` starts no load. 🤖 Written by [Claude Code](https://claude.com/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 @charlieforward9.
Changing
geotiffon aCOGLayerwhile the old file was still opening could leave the layer drawing the old file and callonGeoTIFFLoadwith it. The old parse was never aborted, so if it finished last it overwrote the new file's state. If it finished first,isLoadedturned true early.updateStatenow aborts the previous parse and gives each parse its ownAbortController.MultiCOGLayerhad the same race onsourcesand gets the same fix.The new tests in
cog-layer.test.tsandmulti-cog-layer.test.tsfail without this change.