bug: opening a picture freezes the window — no progress, no way to stop it #10

Open
opened 2026-11-16 14:26:49 +00:00 by ben · 0 comments
Owner

Version: 0.1.2 (main @ 41c7fc5)
System: Linux, X11 (XWayland) and Windows 11 — reported by the person using it as "Programm antwortet nicht" when opening files.

Steps to reproduce

  1. Open a large picture (24 MP in the measurement below) with File ▸ Import, a drop on the window, or by starting the app with the path.
  2. Or: a document with a heavy effect such as Neo Glow on a 12 MP picture (see the Neo Glow issue) and any edit that triggers a full render.

What should have happened

The window keeps answering: the picture appears with a progress hint, and a slow operation can be cancelled.

What happened instead

Reading, decoding and dithering all happen inside the UI callback, before the window draws anything, so the desktop marks the app as not responding and clicks are queued until it is done.

fn set_source (main.rs:834) is the whole pipeline, synchronously:

let decoded = std::fs::read(&path) … decode_image_limited(&bytes, MAX_IMAGE_PIXELS) …;
… self.render_full();

It is called straight from the menu, from the drop handler in ui(), and from the batch export. For 24 MP: 1.43 s and 836 MB peak RSS before the first frame is drawn; with Neo Glow on 12 MP it is 66 s. fn load_project has the same shape (read the zip, decode every media/ entry, render).

Nothing in the app can interrupt a render: there is no worker, no progress and no cancel. busy_since only debounces re-renders by 40 ms.

Suggested fix

Move the slow half off the UI thread and keep the last frame on screen:

  1. A worker thread (one is enough; the render already splits itself over the cores) that owns "load this path" and "render these parameters" jobs, handing results back over a channel that ui() drains once per frame.
  2. A generation counter with each job, so a load that finishes late cannot overwrite a newer document — the same rule the GIF export already follows by writing one frame per UI frame.
  3. Esc/a Stop button for a render in flight; a cancelled job drops its result on arrival.
  4. The status line then has something honest to say: "Decoding 6000×4000…", "Rendering… 40 %".

This is the same fix for opening a picture, opening a project and the Neo Glow render, so it is worth doing once rather than per caller.

A check that would catch it

An --audit row that starts a job for a 12 MP picture and asserts the UI loop keeps producing frames (with a frame counter, not with a wall-clock threshold), plus one that a job superseded by a newer generation is discarded.

Version: 0.1.2 (`main` @ 41c7fc5) System: Linux, X11 (XWayland) and Windows 11 — reported by the person using it as "Programm antwortet nicht" when opening files. ## Steps to reproduce 1. Open a large picture (24 MP in the measurement below) with File ▸ Import, a drop on the window, or by starting the app with the path. 2. Or: a document with a heavy effect such as Neo Glow on a 12 MP picture (see the Neo Glow issue) and any edit that triggers a full render. ## What should have happened The window keeps answering: the picture appears with a progress hint, and a slow operation can be cancelled. ## What happened instead Reading, decoding and dithering all happen inside the UI callback, before the window draws anything, so the desktop marks the app as not responding and clicks are queued until it is done. `fn set_source` (`main.rs:834`) is the whole pipeline, synchronously: ```rust let decoded = std::fs::read(&path) … decode_image_limited(&bytes, MAX_IMAGE_PIXELS) …; … self.render_full(); ``` It is called straight from the menu, from the drop handler in `ui()`, and from the batch export. For 24 MP: **1.43 s** and 836 MB peak RSS before the first frame is drawn; with Neo Glow on 12 MP it is **66 s**. `fn load_project` has the same shape (read the zip, decode every `media/` entry, render). Nothing in the app can interrupt a render: there is no worker, no progress and no cancel. `busy_since` only debounces re-renders by 40 ms. ## Suggested fix Move the slow half off the UI thread and keep the last frame on screen: 1. A worker thread (one is enough; the render already splits itself over the cores) that owns "load this path" and "render these parameters" jobs, handing results back over a channel that `ui()` drains once per frame. 2. A generation counter with each job, so a load that finishes late cannot overwrite a newer document — the same rule the GIF export already follows by writing one frame per UI frame. 3. `Esc`/a Stop button for a render in flight; a cancelled job drops its result on arrival. 4. The status line then has something honest to say: "Decoding 6000×4000…", "Rendering… 40 %". This is the same fix for opening a picture, opening a project and the Neo Glow render, so it is worth doing once rather than per caller. ## A check that would catch it An `--audit` row that starts a job for a 12 MP picture and asserts the UI loop keeps producing frames (with a frame counter, not with a wall-clock threshold), plus one that a job superseded by a newer generation is discarded.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ben/openDither#10
No description provided.