Skip to content

Drawings: a drawing stores an image file once, however many times it is placed (#5425) - #10465

Closed
CamWight wants to merge 2 commits into
tangency-labs:drawingsfrom
CamWight:images-on-paper-5426
Closed

CamWight wants to merge 2 commits into
tangency-labs:drawingsfrom
CamWight:images-on-paper-5426

Conversation

@CamWight

@CamWight CamWight commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

A drawing had no way to hold image files for its sheets. Now it stores each image file once, and a sheet can place it as many times as it likes, so a logo on every sheet is one copy in the design file. The next change draws these images on paper.

Part of #5425 (W38e), into drawings: a drawing keeps an image's file once, however many places it sits. Stacked on #10464 for its list type: the first commit here is that PR's, this PR's own is the last. W38e-2 (#10363) gives these files their pixels on paper.

Changes a default: no

What it does

images holds the files and sheet_images each place one sits, so a logo on every sheet costs what one does.

drawing.image.add {sheet, file, rect_mm}:

  • reads a PNG or JPEG through the allowed folders, and checks its bytes and pixels from the header before anything decodes it;
  • reuses a file the drawing already has with the same bytes;
  • saves the bytes (base64) and never the path, so a design still opens with the original file gone;
  • replies with the placement's id, the format and the pixels.

Caps: 4 MiB a file, 9 MiB a drawing, 64 million pixels (geom::paper::MAX_IMAGE_PIXELS), 1000 files, 1000 placements.

A file goes with the last thing that uses it, which Drawing::images_in_use alone says. Reading a drawing refuses a file nothing uses, or a record its file disagrees with. A sheet's list and delete take the placements on it: deleting a sheet that holds images is refused, naming them, unless the call says contents: "delete".

An older drawing has neither list. The last release refuses a drawing saved with them, as a newer format.

Pictures

No visible change yet: no sheet page shows images, and their pixels on paper are #10363. The real-program check is under Validation.

Tests

  • crates/doc/src/drawing/image_tests.rs (9): saved and read back the same, one file on two sheets saved once, a file going with its last placement, ids staying apart, caps read before decoding, a file that lies refused on reading, a placement and its file naming each other, a rectangle on paper with a size, a drawing's counts.
  • crates/engine/src/cmd/drawing_image_tests.rs (6): read and saved without its path in one undo step, the same bytes as one file on each sheet, what isn't an image or breaks a cap refused with nothing changed, a file outside the allowed folders refused, an image that would stop the drawing saving refused, an image the drawing has no room for refused.
  • crates/io/src/design/drawing_tests.rs: an_image_on_a_sheet_round_trips_and_a_lying_one_is_refused.

Planted faults: 26 of 26 caught, across both commits, 6 of them on the list type, then a clean run. 24 were caught on the first pass. The other two, an empty path reaching the reader and no check that the drawing can still be saved, each got a test and were caught when planted again.

What no test reaches

  • Pixels on paper: Drawings: an image file's pixels are read safely and placed on any paper grid (#5425) #10363.
  • Deleting one placement: it waits for selection.delete to take a drawing's objects.
  • render_workspace::tests::progressive_image_controls_route_to_the_registered_host and the solidcraft_gpu library tests gave no result on this PC (see below). Neither goes through this code, and this PR changes nothing in crates/gpu or crates/ui-egui. CI's run is the first full result for them.

Validation

The full gate on this PC ended exit 1. fmt, assets, icons, licences, lists, layers, UI containers, both clippy runs, wasm and web offline all passed; the tests step failed. This PC's gate skips the robustness goldens. What failed:

  • solidcraft-cli help_output and kill_mid_save went over their time limits. In fuzz_refuses_an_argument_it_does_not_take, fuzz stray didn't answer within its 20 s, which the test reports as "kept running". In killed_mid_save_the_old_file_survives, the saver hadn't got far enough within its 20 s (the binary took 1811 s in all). Both pass alone and match drawings 9b73ec8:

    drawings this PR
    help_output alone 8 of 8, 6.74 s 8 of 8, 6.79 s
    kill_mid_save alone pass, 8.14 s pass, 8.33 s
    fuzz stray, one CPU, median of 5 1.108 s 1.100 s
    30 saves, one CPU, median of 5 1.770 s 1.790 s

    Load is my inference, not proven: 80 test binaries ran on the gate's 8 CPUs, and these two failed in none of the 11 earlier gate logs I checked. Across the whole PC the load had a mean of 54% and a maximum of 81%.

  • Engine library: 3002 passed, 1 failed, pattern_of_512_hole_cuts_finishes_in_reasonable_time, a timing test that has failed under load here before.

  • solidcraft_ui_egui library: an access violation (0xc0000005) partway, and many_faces_are_classified_quickly failed. I don't know the violation's cause. Rerun alone in the gate's profile, without the test below: 3600 passed, 0 failed, 14 ignored, no crash, and many_faces_are_classified_quickly passed. That rerun used the gate's binary, from a commit that differs from this head only by a code comment.

  • progressive_image_controls_route_to_the_registered_host spins one thread with no result: it was still running in the gate, and alone it hung past 420 s, with Intel's Vulkan driver disabled. An earlier gate on a commit without this work shows the same test with no result. I haven't run it on current drawings.

  • solidcraft_gpu library: I stopped it after 1 h 42 min, so it has no result.

Real program, on a plain test design through the control channel, safe mode:

  • a PNG goes on a sheet and reports its own pixels, [400, 300];
  • three placements get three ids, and undo takes one;
  • a broken file, a 10 MiB file and a backward rectangle are refused;
  • three placements save the file once: design 490,011 bytes, logo 360,473 bytes;
  • reopened with the PNG deleted, the sheet still has its image, and drawing.sheet.delete refuses, naming it;
  • contents: "delete" works, the design saves again and still opens, and there are no crash reports.

Integration status

Based on drawings 9b73ec8.

Refs #5425, #860

@github-actions github-actions Bot added area:doc timeline, components, parameters, naming area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs) area:kernel B-rep kernel, booleans, blends, STEP/IGES labels Nov 1, 2026
@CamWight CamWight changed the title Sheet images: a drawing keeps an image's file once, however many places it sits (#5425, W38e-1) Sheet images W38e-1: a drawing stores an image file once, however many times it is placed (#5425) Nov 2, 2026
@CamWight CamWight changed the title Sheet images W38e-1: a drawing stores an image file once, however many times it is placed (#5425) Drawings: a drawing stores an image file once, however many times it is placed (#5425) Nov 3, 2026
CamWight and others added 2 commits November 3, 2026 12:23
…ngency-labs#5426)

Each kind on a sheet writes out the same add, find by halves, cap, order and check loop. ById holds
those, so a kind's own file holds only its own rules, and the file's bytes don't change: it saves as
the plain list. Views and dimensions stay on their own lists for now, since other work is on them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngency-labs#5426 W38e-1)

images holds the files and sheet_images each place one sits, so a logo on every sheet costs what one
does. drawing.image.add reads the file (bytes and pixels checked from its header before anything
decodes it), reuses a file with the same bytes, and saves the bytes without the path. A file goes
with the last thing that uses it, which Drawing::images_in_use alone says, and reading a drawing
refuses a file nothing uses or a record its file disagrees with. A sheet's list and delete take the
placements on it. Deleting one placement waits for selection.delete to take a drawing's objects. Its
pixels on paper are W38e-2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CamWight
CamWight force-pushed the images-on-paper-5426 branch from 1d6ff5b to 28aabd4 Compare November 3, 2026 13:06
@CamWight

CamWight commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Carried in by #10926: its squash into drawings (3 Nov) brought in this PR's commits, so a replay would be empty. Closing it as no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:doc timeline, components, parameters, naming area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs) area:kernel B-rep kernel, booleans, blends, STEP/IGES

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant