Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a5463c3
fix(ui): hold the web app's save, share and export buttons to the dow…
Mavrick-F Nov 29, 2026
d46727d
Merge remote-tracking branch 'upstream/main' into fix/web-download-me…
Mavrick-F Nov 29, 2026
dbbb928
Merge remote-tracking branch 'upstream/main' into fix/web-download-me…
Mavrick-F Nov 29, 2026
bedcaae
test(ui): compare the offered name without a clone
Mavrick-F Nov 29, 2026
344499c
refactor(engine): name the absence of a download limit, and say which…
Mavrick-F Nov 29, 2026
42dc73c
fix(web): stop picture and document downloads as they pass the limit
Mavrick-F Nov 29, 2026
a91af92
fix(ui): deliver the files already waiting before a button's own
Mavrick-F Nov 29, 2026
bf625f4
Merge remote-tracking branch 'upstream/main' into fix/web-picture-limits
Mavrick-F Nov 29, 2026
968e552
fix(tiles): hold an archive's directories to its limit as tiles are a…
Mavrick-F Nov 29, 2026
3ba19ea
Merge remote-tracking branch 'upstream/main' into fix/web-download-me…
Mavrick-F Nov 29, 2026
79bbfc9
Merge branch 'fix/web-download-memory' into fix/web-picture-limits
Mavrick-F Nov 29, 2026
16e68e3
fix(engine): hold the web app's printed map to the download limit
Mavrick-F Nov 29, 2026
f319c2b
Merge remote-tracking branch 'upstream/main' into fix/web-picture-limits
Mavrick-F Nov 29, 2026
9a69595
fix(render): don't count an SVG's places for pictures, and print a ma…
Mavrick-F Nov 29, 2026
2167d4c
fix(render): hold Print Map to its file's size, and stop a PDF page a…
Mavrick-F Nov 29, 2026
59e381c
fix(render): leave the places kept for pictures out of every check of…
Mavrick-F Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions crates/data/src/capped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ impl Limit {
}

/// Whether there is a limit to pass: false for [`Limit::none`].
pub(crate) fn bounded(&self) -> bool {
pub fn bounded(&self) -> bool {
self.max != usize::MAX
}

/// The most bytes the limit holds.
pub fn most(&self) -> usize {
self.max
}

/// Refuses, and notes the limit passed, when files that come to `bytes` can't be held: for a
/// writer to ask before it builds a large piece of them that would then be refused.
/// writer to ask before it builds a large piece of them that would then be refused, or as it
/// makes a file somewhere else than a buffer of this limit.
pub fn fits(&self, bytes: usize) -> Result<()> {
if bytes <= self.max {
return Ok(());
Expand All @@ -67,11 +73,6 @@ impl Limit {
self.fits(self.held.load(Ordering::Relaxed).saturating_add(more))
}

/// The most bytes it holds.
pub(crate) fn max(&self) -> usize {
self.max
}

/// An empty buffer counted against this limit.
pub fn buffer(&self) -> Buffer<'_> {
Buffer { file: Vec::new(), at: 0, limit: self, charged: 0, room: None }
Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ fn projected_bytes_within(ds: &Dataset, ext: &str, crs: Crs, limit: &Limit) -> R
/// layer whole would take, when the features are more than `limit` holds: the copy is held beside
/// the layer and the file.
fn copy_fits(ds: &Dataset, crs: Crs, limit: &Limit) -> Result<()> {
let (needs, room) = (ds.features.held_bytes(), limit.max());
let (needs, room) = (ds.features.held_bytes(), limit.most());
if needs <= room {
return Ok(());
}
Expand Down
1 change: 1 addition & 0 deletions crates/data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod memory;
pub mod ogc;
pub mod osm;
pub mod photo;
pub mod png;
pub mod progress;
pub mod provenance;
#[cfg(not(target_arch = "wasm32"))]
Expand Down
162 changes: 162 additions & 0 deletions crates/data/src/png.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
//! A PNG written a row at a time (ISO/IEC 15948), for a picture whose file is held to a limit
//! ([`crate::capped::Limit`]): it goes into the file as it is compressed, so neither a second copy
//! of its pixels nor its compressed stream is held beside it.

use std::io::{Error, ErrorKind, Write};

use flate2::write::ZlibEncoder;
use flate2::{Compression, Crc};

use crate::capped::write_pieces;

/// The bytes of a pixel: red, green, blue and alpha, 8 bits each.
const PIXEL: usize = 4;

/// Writes an 8-bit RGBA picture of `width` × `height` pixels to `out` as a PNG. `row` is asked
/// for each row in turn from the top, and fills it with its pixels' red, green, blue and alpha,
/// the colours not multiplied by the alpha. It stops at the first write `out` refuses, and
/// between rows on Cancel.
pub fn write_rgba<W: Write + ?Sized>(out: &mut W, width: u32, height: u32, mut row: impl FnMut(&mut [u8])) -> std::io::Result<()> {
let bytes = usize::try_from(width)
.ok()
.and_then(|w| w.checked_mul(PIXEL))
.filter(|bytes| *bytes > 0 && *bytes < usize::MAX && height > 0)
.ok_or_else(|| Error::from(ErrorKind::InvalidInput))?;
out.write_all(b"\x89PNG\r\n\x1a\n")?;
let mut header = Vec::with_capacity(13);
header.extend_from_slice(&width.to_be_bytes());
header.extend_from_slice(&height.to_be_bytes());
// 8 bits a channel, colour with alpha, then the one compression, filter and no interlacing.
header.extend_from_slice(&[8, 6, 0, 0, 0]);
chunk(out, b"IHDR", &header)?;
// The rows make one zlib stream, cut into data chunks as it comes out.
let mut data = ZlibEncoder::new(ImageData(&mut *out), Compression::default());
// This row and the one above it (zero above the first), and the smallest filtered form of the
// row so far beside the one being tried, each behind its filter's number.
let (mut line, mut above) = (vec![0; bytes], vec![0; bytes]);
let (mut best, mut tried) = (vec![0; bytes + 1], vec![0; bytes + 1]);
for _ in 0..height {
crate::progress::check().map_err(|e| Error::other(e.to_string()))?;
row(&mut line);
Comment on lines +38 to +40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row loop has no Cancel look. A 8192 × 8192 picture is 8,192 rows of filtering and compressing (the PR's own timings put a 4096² noise picture at about 2.5 s), and nothing between rows calls progress::check, so a cancelled download export waits for the whole picture. The download path runs in the background (exports::runs_in_background), so Cancel is supposed to be seen between items of a long loop. The fix is one line; Error::other is already used in capped.rs:

Suggested change
for _ in 0..height {
row(&mut line);
for _ in 0..height {
crate::progress::check().map_err(|e| Error::other(e.to_string()))?;
row(&mut line);

The encode_png path this replaces had the same gap, so this isn't a regression. The new loop is the place to add the look, or the doc comment should say the picture is one long step. Confidence about 60% that the rule applies as written; I did not run cancelling_at_each_check_leaves_nothing_behind.

Category: agents-md

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the next push: the loop looks at Cancel at each row, and its comment says so. Only a file with a limit comes this way, which is the browser, whose one thread cannot be cancelled while it runs, so it is for a caller that can.

filter(&line, &above, &mut best, &mut tried);
data.write_all(&best)?;
std::mem::swap(&mut line, &mut above);
}
data.finish()?;
chunk(out, b"IEND", &[])
}

/// A chunk: its length, its four-letter kind, `data`, and the CRC-32 of the kind and the data.
fn chunk<W: Write + ?Sized>(out: &mut W, kind: &[u8; 4], data: &[u8]) -> std::io::Result<()> {
let length = u32::try_from(data.len()).map_err(|_| Error::from(ErrorKind::InvalidInput))?;
out.write_all(&length.to_be_bytes())?;
out.write_all(kind)?;
write_pieces(out, data)?;
let mut crc = Crc::new();
crc.update(kind);
crc.update(data);
out.write_all(&crc.sum().to_be_bytes())
}

/// Writes what it is given to a PNG as image data chunks.
struct ImageData<'a, W: Write + ?Sized>(&'a mut W);

impl<W: Write + ?Sized> Write for ImageData<'_, W> {
fn write(&mut self, data: &[u8]) -> std::io::Result<usize> {
if !data.is_empty() {
chunk(self.0, b"IDAT", data)?;
}
Ok(data.len())
}

fn flush(&mut self) -> std::io::Result<()> {
self.0.flush()
}
}

/// Leaves in `best`, behind its filter's number, the filtered form of `line` (under `above`) that
/// is likely to compress smallest: the one whose bytes, taken as signed, sum to the least, as the
/// PNG specification suggests. `tried` is room for the others.
fn filter(line: &[u8], above: &[u8], best: &mut Vec<u8>, tried: &mut Vec<u8>) {
let mut least = u64::MAX;
for kind in 0..5 {
if let Some((number, filtered)) = tried.split_first_mut() {
*number = kind;
match kind {
0 => predicted(line, above, filtered, |_, _, _| 0),
1 => predicted(line, above, filtered, |left, _, _| left),
2 => predicted(line, above, filtered, |_, up, _| up),
// The mean of the two, rounded down, without their sum.
3 => predicted(line, above, filtered, |left, up, _| (left & up) + ((left ^ up) >> 1)),
_ => predicted(line, above, filtered, paeth),
}
// In pieces whose sums fit 32 bits, which add faster.
let sum = filtered
.chunks(1 << 16)
.map(|piece| u64::from(piece.iter().map(|b| u32::from((*b).min(b.wrapping_neg()))).sum::<u32>()))
.sum();
if sum < least {
least = sum;
std::mem::swap(best, tried);
}
}
}
}

/// Writes to `out` each byte of `line` less what `predict` makes of the bytes a pixel to its left,
/// above it, and above that left one; zero for those off the picture's left.
#[inline]
fn predicted(line: &[u8], above: &[u8], out: &mut [u8], predict: impl Fn(u8, u8, u8) -> u8) {
for ((to, byte), up) in out.iter_mut().zip(line).zip(above).take(PIXEL) {
*to = byte.wrapping_sub(predict(0, *up, 0));
}
let rest = out.iter_mut().skip(PIXEL);
let right = line.get(PIXEL..).unwrap_or_default().iter().zip(line);
let upper = above.get(PIXEL..).unwrap_or_default().iter().zip(above);
for (to, ((byte, left), (up, corner))) in rest.zip(right.zip(upper)) {
*to = byte.wrapping_sub(predict(*left, *up, *corner));
}
}

/// The Paeth predictor (the PNG specification's): of the bytes left, above and above-left, the one
/// nearest `left + up - corner`, ties going to the left one and then the one above.
fn paeth(left: u8, up: u8, corner: u8) -> u8 {
let (a, b) = (i16::from(up) - i16::from(corner), i16::from(left) - i16::from(corner));
let (to_left, to_up, to_corner) = (a.abs(), b.abs(), (a + b).abs());
if to_left <= to_up && to_left <= to_corner {
left
} else if to_up <= to_corner {
up
} else {
corner
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::capped::Limit;

/// A picture past its limit is refused as its file passes it, the rows after that never asked
/// for.
#[test]
fn a_png_past_its_limit_stops_asking_for_rows() {
// Noise, which hardly compresses: 4,000 bytes a row.
let mut state = 7u32;
let mut asked = 0;
let limit = Limit::new(40_000);
let made = limit.file(|out| {
write_rgba(out, 1000, 1000, |line| {
asked += 1;
line.fill_with(|| {
state = state.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
(state >> 24) as u8
});
})?;
Ok(())
});
assert!(made.is_err() && limit.passed());
// The compressor hands on what it makes every few tens of rows.
assert!(asked < 100, "{asked} rows asked for");
}
}
4 changes: 2 additions & 2 deletions crates/data/tests/projected_download_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ fn growth(run: impl FnOnce()) -> usize {
}

/// The CSV notices, counted before a file is written, then each format, of which `shp`, `parquet`
/// and `fgb` need the layer whole in the other system. The last write a layer of one feature, whose text alone is
/// as large, and count what KML loses of it.
/// and `fgb` need the layer whole in the other system. The `value` cases use a layer of one feature
/// whose text is as large as that whole layer: three formats, then what KML loses of it.
const CASES: [&str; 13] =
["notices", "geojson", "csv", "kml", "kmz", "gpx", "shp", "parquet", "fgb", "value geojson", "value csv", "value kml", "value notices"];

Expand Down
24 changes: 24 additions & 0 deletions crates/engine/src/cmd/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ impl Room {
}
}

/// What `make` makes of a file held to the limit it is given. Where the file is downloaded
/// (`download`: the room it has, and its name) that is the room, and a file stopped as it passed
/// it is refused as such; where it is written, there is no limit but memory.
pub(crate) fn held_to<T, E: std::fmt::Display>(
download: Option<(Room, &str)>,
make: impl FnOnce(&Limit) -> Result<T, E>,
) -> Result<T, String> {
let limit = download.map_or_else(Limit::none, |(room, _)| Limit::new(room.bytes));
make(&limit).map_err(|why| match download {
Some((room, path)) if limit.passed() => room.refusal(path),
_ => why.to_string(),
})
}
Comment on lines +149 to +158

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats Room::encode (just above): both build a Limit::new(room.bytes), then turn a passed limit into room.refusal(path). They differ on every other error. Room::encode prefixes the path ({path}: {e}), but held_to returns the bare message, so a PNG or PDF encode error reaches the user without its file name.

Suggest one helper with the path prefix in both cases, with Room::encode and Output::held_to calling it, so the two cannot drift apart.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: the exports that call it put the file name on their own errors, so one helper needs that settled in each.


/// What to do about a file too large to download.
pub(crate) const SMALLER: &str = "make a smaller file (fewer features or layers, a smaller size or fewer pages), or use the desktop app";

Expand All @@ -165,11 +179,21 @@ impl<'a> Output<'a> {
Ok(Output { path, room: s.download_room()? })
}

/// Whether it is held to a limit: downloaded, to a front end that has one.
pub(crate) fn limited(self) -> bool {
self.most() != NO_DOWNLOAD_LIMIT
}

/// Whether it is made to be downloaded.
pub(crate) fn downloads(self) -> bool {
self.room.is_some()
}

/// [`held_to`] for this file.
pub(crate) fn held_to<T, E: std::fmt::Display>(self, make: impl FnOnce(&Limit) -> Result<T, E>) -> Result<T, String> {
held_to(self.room.map(|room| (room, self.path)), make)
}

/// The most bytes it may come to.
pub(crate) fn most(self) -> usize {
self.room.map_or(usize::MAX, |room| room.bytes)
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/cmd/gp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3921,8 +3921,8 @@ fn queue(s: &mut Session, file_name: String, bytes: Arc<Vec<u8>>, from: Delivery
};
let cap = s.download_cap();
let held = if cap == super::exports::NO_DOWNLOAD_LIMIT { 0 } else { s.waiting_download_bytes() };
// An export whose writer takes a limit was stopped at it; this is what holds the others (a
// picture, an SVG, a PDF past its pages, the file a raster layer holds) to it.
// An export whose writer takes a limit was stopped at it; this is what holds the others, such as
// the file a raster layer holds, to it.
// Measured as the queue counts what waits: by what the file holds, its spare room included.
let size = bytes.capacity();
if matches!(from, Delivery::Export(_)) && size > cap {
Expand Down
26 changes: 16 additions & 10 deletions crates/engine/src/cmd/layout/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub fn layout_bytes_with(
layout_bytes_for(s, li, pdf, dpi, all, georeference, options, None)
}

/// [`layout_bytes_with`] for a file that may be downloaded to the path given: a PDF's pages are
/// then held to that room too, and stopped as they pass it.
/// [`layout_bytes_with`] for a file that may be downloaded to the path given: the file, and a
/// PDF's pages as they are drawn, are then held to that room, and stopped as they pass it.
#[expect(clippy::too_many_arguments, reason = "the export's own settings")]
fn layout_bytes_for(
s: &mut Session,
Expand Down Expand Up @@ -288,7 +288,7 @@ pub(in crate::cmd::layout) fn layout_bytes_inner(
}
} else {
let img = rustgis_render::layout::render(layout, &mut s.project.maps, dpi, &info)?;
png = Some(img.encode_png().map_err(|e| e.to_string())?);
png = Some(crate::cmd::exports::held_to(download, |limit| rustgis_render::png::within(&img, limit))?);
}
// A cancelled export stops here, its layout put back below.
rustgis_data::progress::step(1).map_err(|e| e.to_string())?;
Expand Down Expand Up @@ -330,7 +330,8 @@ pub(in crate::cmd::layout) fn layout_bytes_inner(
if !pdf {
return png.ok_or_else(|| "nothing to draw".to_string());
}
let (bytes, outlined) = rustgis_render::pdf::write_with(&pages, &saved.name, options);
let (bytes, outlined) =
crate::cmd::exports::held_to(download, |limit| rustgis_render::pdf::write_with_within(&pages, &saved.name, options, limit))?;
outlined_notice(s, &outlined);
Ok(bytes)
}
Expand Down Expand Up @@ -519,11 +520,11 @@ pub(crate) fn export_work(s: &Session, p: &Value) -> Result<crate::cmd::exports:
let mut copy = Session::new(project);
let mut held = None;
let written = (|| {
let to = download.map(|room| (room, path.as_str()));
let bytes = if svg {
layout_svg(&mut copy, li, dpi)?.into_bytes()
layout_svg(&mut copy, li, dpi, to)?.into_bytes()
} else {
let download = download.map(|room| (room, path.as_str()));
layout_bytes_for(&mut copy, li, pdf, dpi, all, georeference, options, download)?
layout_bytes_for(&mut copy, li, pdf, dpi, all, georeference, options, to)?
};
rustgis_data::progress::check().map_err(|e| e.to_string())?;
let len = bytes.len();
Expand All @@ -538,8 +539,9 @@ pub(crate) fn export_work(s: &Session, p: &Value) -> Result<crate::cmd::exports:
}

/// The layout `li` as it is now (a map series at its current page) as SVG, kept as vectors with
/// pictures at `dpi`; a frame too large for vectors is a picture, and the export says so.
pub(in crate::cmd::layout) fn layout_svg(s: &mut Session, li: usize, dpi: f64) -> Result<String, String> {
/// pictures at `dpi`; a frame too large for vectors is a picture, and the export says so. Where
/// it is downloaded (`download`: its room and name), it is stopped as it passes the room.
fn layout_svg(s: &mut Session, li: usize, dpi: f64, download: Option<(crate::cmd::exports::Room, &str)>) -> Result<String, String> {
let dpi = if dpi.is_finite() { dpi.clamp(36.0, 600.0) } else { 150.0 };
let current = s.project.layouts.get(li).ok_or("no layout")?.series.as_ref().map_or(0, |sr| sr.page);
let series = series_info(s, li, current);
Expand All @@ -555,7 +557,11 @@ pub(in crate::cmd::layout) fn layout_svg(s: &mut Session, li: usize, dpi: f64) -
let gaps = rustgis_render::layout::sections_not_drawn(layout, &s.project.maps).into_iter().map(|g| (g, 1)).collect();
let profiles: ProfileNotes = rustgis_render::layout::profiles_not_drawn(layout, &s.project.maps).into_iter().map(|n| (n, 1)).collect();
let ((drawn, unfitted), charts) = rustgis_render::layout::drawn_charts(|| {
rustgis_render::layout::unfitted_legends(|| rustgis_render::svg::layout_svg(layout, &mut s.project.maps, dpi, &info))
rustgis_render::layout::unfitted_legends(|| {
crate::cmd::exports::held_to(download, |limit| {
rustgis_render::svg::layout_svg_within(layout, &mut s.project.maps, dpi, &info, limit)
})
})
});
let (text, pictured) = drawn?;
let chart_notes = chart_notice_lines(layout, &charts);
Expand Down
11 changes: 5 additions & 6 deletions crates/engine/src/cmd/presentation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Publish › Presentation (New and Import Presentation), Publish › Page (Map, Blank, Image, Video), and
//! Publish › Save As (Presentation File) and Output (Export Presentation): presentations.

use base64::Engine;
use rustgis_geom::Coord;
use rustgis_map::Rgba;
use rustgis_map::layout::{ElementKind, FrameShape, Layout};
Expand Down Expand Up @@ -513,8 +512,8 @@ pub fn export_bytes(s: &mut Session, i: usize, format: &str, dpi: f64) -> Result
export_within(s, i, format, dpi, super::exports::Output::UNLIMITED)
}

/// [`export_bytes`] for the file `out` describes: a downloaded PDF or slideshow stops at the page
/// that passes its room.
/// [`export_bytes`] for the file `out` describes: a downloaded file, and the pages of a PDF or
/// slideshow as they are drawn, are stopped as they pass its room.
fn export_within(s: &mut Session, i: usize, format: &str, dpi: f64, out: super::exports::Output<'_>) -> Result<(Vec<u8>, usize), String> {
let revision = |s: &Session| {
rustgis_render::archive_revisions(s.project.presentations.get(i).into_iter().flat_map(|p| {
Expand Down Expand Up @@ -548,7 +547,7 @@ fn export_bytes_inner(
}
if format == "png" {
let img = draw_page(s, i, 0, dpi)?;
return Ok((img.encode_png().map_err(|e| e.to_string())?, 1));
return Ok((out.held_to(|limit| rustgis_render::png::within(&img, limit))?, 1));
}
let mut pdf_pages = Vec::new();
let mut slides = String::new();
Expand All @@ -570,7 +569,7 @@ fn export_bytes_inner(
} else {
let img = draw_page(s, i, k, dpi)?;
let page = s.project.presentations.get(i).and_then(|p| p.pages.get(k)).ok_or("no page")?;
let png = base64::engine::general_purpose::STANDARD.encode(img.encode_png().map_err(|e| e.to_string())?);
let png = out.held_to(|limit| rustgis_render::png::base64_within(&img, limit, slides.len()))?;
held += png.len();
let body = match &page.kind {
// The poster is the drawn page, which already shows the title and caption. The
Expand Down Expand Up @@ -608,7 +607,7 @@ fn export_bytes_inner(
crate::durable::notify(s, &output_report);
if format == "pdf" {
super::layout::pictured_notices(s, &frames_pictured, &pages_pictured);
return Ok((rustgis_render::pdf::write(&pdf_pages, &name), n));
return Ok((out.held_to(|limit| rustgis_render::pdf::write_within(&pdf_pages, &name, limit))?, n));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twin the change missed: the PR drops the drawing-cost pre-check for Print Map, because Page::len for a vector page is Drawing::cost (an uncompressed estimate, while the PDF's streams are deflated). Three other PDF writers still refuse on that estimate before writing, and they will still refuse files that would fit:

  • here, presentation.rs:602 (out.check(held) where held sums Page::len over the pages),
  • report.rs:1246 (held > room.bytes on Page::len),
  • layout/export.rs:277 (the same check on Page::len).

Each of these runs before write_within gets to stop the file at its real size. Either remove the per-page estimate check and let held_to decide, as the Print Map fix did, or say why these PDFs keep it. I checked the other families: the read routes, overlay tools and add/open commands are not touched by this diff.

Category: bug

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept on purpose, and as it was on main since #3124. These three hold every page until the document is written, so the estimate is what bounds the memory of a long document as it is drawn: without it, pages could pile up far past the room before the writer saw a byte. Print Map has one page, whose vectors are at most 64 MiB in the browser, so there it bounded nothing. The cost is that a document close to the room can be refused though its compressed file would fit, with the refusal saying to make it smaller; the description now says so.

}
let html = format!(
r#"<!doctype html>
Expand Down
Loading
Loading