diff --git a/src/client/graphics/layers/StructureLayer.ts b/src/client/graphics/layers/StructureLayer.ts index 32d836256..5bc165b92 100644 --- a/src/client/graphics/layers/StructureLayer.ts +++ b/src/client/graphics/layers/StructureLayer.ts @@ -130,12 +130,27 @@ export class StructureLayer implements Layer { if (context === null) throw new Error("2d context not supported"); this.context = context; + // Firefox's GPU limit is 8192, only known browser issue + const maxTextureSize = 8192; + const scaleX = maxTextureSize / this.game.width(); + const scaleY = maxTextureSize / this.game.height(); + const targetScale = Math.min(2, scaleX, scaleY); + this.canvas.width = Math.max( + 1, + Math.floor(this.game.width() * targetScale), + ); + this.canvas.height = Math.max( + 1, + Math.floor(this.game.height() * targetScale), + ); + // Enable smooth scaling this.context.imageSmoothingEnabled = true; this.context.imageSmoothingQuality = "high"; - - this.canvas.width = this.game.width() * 2; - this.canvas.height = this.game.height() * 2; + this.context.scale( + this.canvas.width / (this.game.width() * 2), + this.canvas.height / (this.game.height() * 2), + ); Promise.all( Array.from(this.unitIcons.values()).map((img) =>