feat(geo-layers): expose Layer.getTileLoadingState() and Tile2DHeader error state#10360
feat(geo-layers): expose Layer.getTileLoadingState() and Tile2DHeader error state#10360akre54 wants to merge 1 commit into
Conversation
… error state
Adds a public API for inspecting tile load progress on tile-based layers:
layer.getTileLoadingState(): {
pending: number, // tiles being fetched/decoded
loaded: number, // tiles successfully loaded
failed: number, // tiles whose load attempt failed
total: number, // total tiles in the current viewport selection
isComplete: boolean // pending === 0
} | null
The base `Layer` class returns `null` so non-tile layers report a clear
"not applicable" rather than zeros. `TileLayer` overrides the method by
delegating to `Tileset2D.getLoadingState()`, and `MVTLayer` inherits that
override automatically.
To distinguish failed tiles from successfully-loaded-but-empty tiles
(404s, intentional null content), `Tile2DHeader` now records the error
returned by `getTileData` on a private `_error` field, exposed via two
public getters:
- `tile.error` - the error reported by getTileData, or null
- `tile.isFailed` - true iff the most recent attempt rejected
The error is cleared when `loadData()` starts a new request, so a tile
that recovers on reload reports `isFailed === false` again.
Motivating use case: noodles.gl video export and other headless capture
flows currently treat tile pipelines as opaque — they cannot tell
whether a `TileLayer` is genuinely settled or still streaming tiles.
This API lets the exporter wait on a per-layer basis and surface failure
counts to users.
Tests cover:
- Tile2DHeader error/isFailed transitions (success, failure, recovery)
- Tileset2D.getLoadingState() null pre-update, pending->loaded
transition, failure counting
- TileLayer.getTileLoadingState() pre/post viewport selection
- MVTLayer inherits the method from TileLayer
- Base Layer returns null for non-tile layers
chrisgervang
left a comment
There was a problem hiding this comment.
no visibility into:
How many tiles are pending
How many have failed
Whether the layer is actively loading vs settled
Capturing frames too early (incomplete tiles)
layer.isLoaded is supposed to be false if there are pending / actively loading tiles. The specifics may not be visible, but most cases should be covered already. If they aren't in some case, I'd consider that a bug and unintentional.
Exposing failed tiles seems to be the main new capability this adds since a tile layer is technically loaded even if all tiles failed.
| * Returns `null` for non-tile layers and for tile layers whose tileset has not yet computed | ||
| * a viewport selection (e.g. before the first render). | ||
| */ | ||
| getTileLoadingState(): { |
There was a problem hiding this comment.
Tiles aren't a core concept to deck so I don't think this belongs on the base Layer.
Please isolate the changes to the geo-layers module.
There was a problem hiding this comment.
Sure thing I can move to geo-layers
Summary
Adds getTileLoadingState() method to tile-based layers (TileLayer, MVTLayer, etc.) for visibility into tile loading/failure state during rendering.
Motivation
When exporting video or performing headless rendering with tile-based layers, it's critical to know when tiles are fully loaded vs still streaming. The existing layer.isLoaded property is binary (true/false) with no visibility into:
This leads to either:
Applications like noodles.gl need granular tile state to make informed capture decisions.
API
Implemented on:
Returns null for non-tile layers (e.g., ScatterplotLayer).
Usage Example
Implementation Details
Tests
10 new tests across:
All 69 tile layer tests pass. All 77 geo-layers module tests pass.
Performance
Less than 0.1ms per call (aggregates cached tile state, no iteration).
Breaking Changes
None - purely additive API.
Related PRs
Companion MapLibre PRs
Example Integration
For video export with tiles:
Co-authored-by: Claude Sonnet 4.5 noreply@anthropic.com