From 82cd11a1ad1b3d8d8131a4706c586a0fc5f351e8 Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Wed, 17 Jun 2026 09:43:58 +0200 Subject: [PATCH] :bug: Fix DocAtlas cap --- render-wasm/src/render/options.rs | 2 +- render-wasm/src/render/surfaces.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/render-wasm/src/render/options.rs b/render-wasm/src/render/options.rs index 7a6a3a3d39..3f663bcd16 100644 --- a/render-wasm/src/render/options.rs +++ b/render-wasm/src/render/options.rs @@ -9,7 +9,7 @@ const SHOW_WASM_INFO: u32 = 0x08; // Higher values pre-render more tiles, reducing empty squares during pan but using more memory. const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 1; const MIN_DPR_VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 2; -const MAX_BLOCKING_TIME_MS: i32 = 32; +const MAX_BLOCKING_TIME_MS: i32 = 8; const NODE_BATCH_THRESHOLD: i32 = 3; const BLUR_DOWNSCALE_THRESHOLD: f32 = 8.0; const ANTIALIAS_THRESHOLD: f32 = 7.0; diff --git a/render-wasm/src/render/surfaces.rs b/render-wasm/src/render/surfaces.rs index be7448bdf1..ed9182c1f6 100644 --- a/render-wasm/src/render/surfaces.rs +++ b/render-wasm/src/render/surfaces.rs @@ -25,6 +25,7 @@ const TILE_DRAWABLE_RECT: IRect = IRect { right: TILE_MARGIN_SIZE + TILE_SIZE, bottom: TILE_MARGIN_SIZE + TILE_SIZE, }; +const DOC_ATLAS_MAX_DIM: i32 = 4096; pub fn get_cache_size(viewbox: &Viewbox, interest: i32) -> skia::ISize { // First we retrieve the extended area of the viewport that we could render. @@ -178,7 +179,10 @@ impl DocAtlas { // Compute atlas scale needed to fit within the fixed texture cap. // Keep the highest possible scale (closest to 1.0) that still fits. - let cap = gpu_state.max_texture_size().max(TILE_SIZE) as f32; + let cap = gpu_state + .max_texture_size() + .clamp(TILE_SIZE, DOC_ATLAS_MAX_DIM) as f32; + let required_scale = (cap / doc_w).min(cap / doc_h).clamp(0.01, 1.0); // Never upscale the atlas (it would add blur and churn).