Skip to content

Clamp oversized imagery tiles to maximum texture size#13221

Open
TJKoury wants to merge 1 commit intoCesiumGS:mainfrom
TJKoury:fix/clamp-oversized-imagery-textures
Open

Clamp oversized imagery tiles to maximum texture size#13221
TJKoury wants to merge 1 commit intoCesiumGS:mainfrom
TJKoury:fix/clamp-oversized-imagery-textures

Conversation

@TJKoury
Copy link
Contributor

@TJKoury TJKoury commented Feb 20, 2026

Imagery providers can return tiles larger than the GPU's MAX_TEXTURE_SIZE (e.g. 8192 on Firefox vs 16384 on Chrome). When this happens, the Texture constructor throws a DeveloperError with no recovery path, breaking tile rendering.

This adds a downscale step in ImageryLayer._createTextureWebGL that clamps non-compressed imagery to ContextLimits.maximumTextureSize via an offscreen canvas before texture creation. Compressed textures (KTX2) are unaffected since their dimensions are typically controlled by the provider.

Testing: Reproduced on Firefox (MAX_TEXTURE_SIZE=8192) with a WMS provider serving large tiles. After this fix, oversized tiles are downscaled transparently instead of throwing.

Imagery providers can return tiles larger than the GPU MAX_TEXTURE_SIZE (e.g. 8192 on Firefox). This causes a DeveloperError in the Texture constructor with no recovery path.

Downscale non-compressed imagery via an offscreen canvas before texture creation when dimensions exceed the limit.
@github-actions
Copy link

Thank you for the pull request, @TJKoury!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Mar 3, 2026

Thanks for the PR @TJKoury! @javagl would you be able to review?

Assuming we agree on the improvement, could we get an update to CHANGES.md and maybe a unit test?

@javagl
Copy link
Contributor

javagl commented Mar 3, 2026

The change looks small, local, and straightforward. I cannot imagine any issues with that.

(Well, of course I can. Someone will create an imagery provider that serves 32768x32768 pixel images that are completely white, and have one black pixel at the lower right border, and then complain that this "rectangle grid" that they expect there does not appear, because the scaling is rounding away that black pixel - let's way for the issue report of this case)

Unit tests for this could be tricky - at least, they won't run in CI, and given the platform-dependency, one might have to use some "mock ContextLimits". Related to that: Is there an "easy" way to test this? (I can try to create or set up some "dummy image server", but wondered whether someone has already an off-the-shelf solution for that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants