From 9d4b88b06b9dd0e8f696664011a1c50d933ddcf3 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 24 Dec 2025 13:14:16 +0100 Subject: [PATCH] Increase WebGL buffer cap from 4096 to 7232 for sharper text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Binary search testing found 7232px is the maximum safe buffer dimension before the Y=0 rendering bug appears on macOS Apple Silicon. This allows ~3616px CSS width at DPR 2 before scaling kicks in, providing sharper text rendering on most displays. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/renderer/WebGLManager.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/renderer/WebGLManager.ts b/src/renderer/WebGLManager.ts index 43a159e..83df43e 100644 --- a/src/renderer/WebGLManager.ts +++ b/src/renderer/WebGLManager.ts @@ -168,9 +168,19 @@ export class WebGLManager { let bufferWidth = Math.round(width * dpr) let bufferHeight = Math.round(height * dpr) - // Cap buffer size to avoid GPU/driver issues with very large framebuffers - // Some systems have rendering issues when buffer dimensions exceed 4096px - const MAX_BUFFER_DIM = 4096 + // Cap buffer size to avoid GPU/driver issues with very large framebuffers. + // On some systems (observed on macOS with Apple Silicon), content rendered at Y=0 + // becomes invisible when the WebGL buffer exceeds a certain size. + // + // This limit (7232px) was found through binary search testing: + // - 7232: works + // - 7234: fails (content at Y=0 disappears) + // + // The value doesn't align with typical GPU limits (4096, 8192, 16384) or memory + // boundaries, suggesting a driver-specific bug rather than a documented limit. + // At DPR 2, this allows ~3616px CSS width before scaling kicks in. + // When this cap is triggered, the canvas is CSS-upscaled with minimal quality loss. + const MAX_BUFFER_DIM = 7232 const maxDim = Math.max(bufferWidth, bufferHeight) if (maxDim > MAX_BUFFER_DIM) { const scale = MAX_BUFFER_DIM / maxDim