From 11a143ec786606640a126dd150338169adc1f62c Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 10 Apr 2026 15:25:16 -0400 Subject: [PATCH] fix: Ensure we reset state when changing sources in MultiCOGLayer --- .../deck.gl-geotiff/src/multi-cog-layer.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/deck.gl-geotiff/src/multi-cog-layer.ts b/packages/deck.gl-geotiff/src/multi-cog-layer.ts index 903df19b..03a825eb 100644 --- a/packages/deck.gl-geotiff/src/multi-cog-layer.ts +++ b/packages/deck.gl-geotiff/src/multi-cog-layer.ts @@ -307,8 +307,19 @@ export class MultiCOGLayer extends CompositeLayer { }); } - override updateState({ changeFlags }: UpdateParameters): void { - if (changeFlags.dataChanged || changeFlags.propsChanged) { + override updateState({ + changeFlags, + props, + oldProps, + }: UpdateParameters): void { + if (changeFlags.dataChanged || props.sources !== oldProps.sources) { + // Reset state so renderLayers() returns null while we re-open COGs. + // Without this, the TileLayer renders with new props but stale state, + // caching tiles with the wrong bands. + this.setState({ + sources: null, + multiDescriptor: null, + }); this._parseAllSources(); } } @@ -494,6 +505,10 @@ export class MultiCOGLayer extends CompositeLayer { 0, ); + console.log( + `Tile (${x}, ${y}, ${z}): fetched bands [${[...bands.keys()].join(", ")}], total byte length: ${byteLength}`, + ); + return { bands, forwardTransform,