From 1dbfb9a468859fb0e0ce228740731e0876bcdcf6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 25 Oct 2026 10:15:44 -0300 Subject: pdfrender 1: PDF pages render off the loop: MuPDF's base context gets locks (fz_locks_context, pthread mutexes), a render lane is a cloned context with its own document opened from the base's shared fz_buffer (no fz_context or fz_document is ever touched by two threads); jobs on io.concurrent, a generation per slot (a stale raster never lands), fz_cookie aborts a job nobody waits for; a page not landed shows its paper, the page past the strip is rendered ahead, the second lane starts once the first is warm; pages kept past their pane for a second open or a Restore (64 MiB, oldest out first); a PDF's watch armed over the bytes it read no longer reopens it (every open parsed the document twice); a far jump's first frame no longer falls back to the page's text --- src/file_watch.zig | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/file_watch.zig') diff --git a/src/file_watch.zig b/src/file_watch.zig index 4aba6c39..ab902e5b 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -496,7 +496,17 @@ pub fn reloadPane( const path = pane.pdfPath() orelse return false; const before = identify(io, path) catch return false; switch (watched.generation) { - .pdf => |accepted| if (accepted) |identity| if (identity.eql(before)) return false, + .pdf => |accepted| if (accepted) |identity| { + if (identity.eql(before)) return false; + } else if (pardes.panes.Pdf.sameBytes(core, pane)) { + // Armed over the bytes the pane opened (a text's baseline is its + // content, a PDF's is what it read): nothing to reload. Parsing + // the document again doubled every PDF's open. + if (watches[id]) |*live| if (live.serial == watched.serial) { + live.generation = .{ .pdf = before }; + }; + return false; + }, .text => {}, } if (!core.reloadWatchedFile(@intCast(id), &.{})) return false; -- cgit v1.3