bug: Stage 2 generates .ti2 / .tiff targets with random seed #163

Closed
opened 2026-08-31 17:54:25 +01:00 by gronod · 0 comments
Owner

Problem Description

When Stage 2 executes ArgyllCMS printtarg to format target pages (.ti2 and .tif files) from a .ti1 target definition, patch layouts on pages are generated non-deterministically. Re-running Stage 2 or opening a previously generated .ti1 file produces a different patch arrangement in .ti2 and new .tif target sheets, breaking reproducibility and making previously printed sheets incompatible with regenerated .ti2 files.

Root Cause Analysis

  1. ArgyllCMS printtarg Default Randomization:
    • By default, printtarg randomizes the target patch distribution across pages using a non-deterministic, time/process-based seed unless explicitly constrained.
  2. Missing Seed / Ordering Arguments in ICCery:
    • In src-tauri/src/commands.rs, build_printtarg_args() builds CLI arguments without passing the ArgyllCMS -R <seed> (fixed pseudo-random seed) or -r (raster order / no randomization) flags.
    • As a result, every invocation of printtarg against the same .ti1 file yields a distinct .ti2 patch layout. If a user prints a target sheet, closes ICCery, and subsequently opens the .ti1 file to resume profiling, regenerating .ti2 causes a mismatch between the physical target print and the .ti2 reference file needed by chartread (Stage 3).

Proposed Solution

  1. Deterministic Target Layout by Default:
    • Update build_printtarg_args in src-tauri/src/commands.rs to pass a deterministic seed flag (e.g. -R 1 or a seed derived deterministically from the .ti1 basename / hash) by default whenever a specific seed is not explicitly specified.
  2. Backend Configuration (PrinttargConfig):
    • Add optional layout control fields to PrinttargConfig:
      • random_seed: Option<u32> (defaults to Some(1) or deterministic seed).
      • no_randomize: Option<bool> (for passing -r if raster order is desired).
  3. Frontend UI Controls (Stage 2):
    • Add a "Patch Layout Order" setting in Stage 2 (Print Layout) or within an Advanced Layout settings drawer:
      • Deterministic Random (Default, Seed = 1): Reproducible pseudo-random distribution.
      • Custom Seed: Allows users to specify a fixed integer seed.
      • Raster Order (-r): Unrandomized sequential patch layout.
  4. Automated Unit Testing:
    • Add unit tests in src-tauri/src/commands.rs verifying that build_printtarg_args includes -R <seed> or -r flags correctly.
### Problem Description When Stage 2 executes ArgyllCMS `printtarg` to format target pages (`.ti2` and `.tif` files) from a `.ti1` target definition, patch layouts on pages are generated non-deterministically. Re-running Stage 2 or opening a previously generated `.ti1` file produces a different patch arrangement in `.ti2` and new `.tif` target sheets, breaking reproducibility and making previously printed sheets incompatible with regenerated `.ti2` files. ### Root Cause Analysis 1. **ArgyllCMS `printtarg` Default Randomization**: - By default, `printtarg` randomizes the target patch distribution across pages using a non-deterministic, time/process-based seed unless explicitly constrained. 2. **Missing Seed / Ordering Arguments in ICCery**: - In `src-tauri/src/commands.rs`, `build_printtarg_args()` builds CLI arguments without passing the ArgyllCMS `-R <seed>` (fixed pseudo-random seed) or `-r` (raster order / no randomization) flags. - As a result, every invocation of `printtarg` against the same `.ti1` file yields a distinct `.ti2` patch layout. If a user prints a target sheet, closes ICCery, and subsequently opens the `.ti1` file to resume profiling, regenerating `.ti2` causes a mismatch between the physical target print and the `.ti2` reference file needed by `chartread` (Stage 3). --- ### Proposed Solution 1. **Deterministic Target Layout by Default**: - Update `build_printtarg_args` in `src-tauri/src/commands.rs` to pass a deterministic seed flag (e.g. `-R 1` or a seed derived deterministically from the `.ti1` basename / hash) by default whenever a specific seed is not explicitly specified. 2. **Backend Configuration (`PrinttargConfig`)**: - Add optional layout control fields to `PrinttargConfig`: - `random_seed: Option<u32>` (defaults to `Some(1)` or deterministic seed). - `no_randomize: Option<bool>` (for passing `-r` if raster order is desired). 3. **Frontend UI Controls (Stage 2)**: - Add a "Patch Layout Order" setting in Stage 2 (Print Layout) or within an Advanced Layout settings drawer: - **Deterministic Random (Default, Seed = 1)**: Reproducible pseudo-random distribution. - **Custom Seed**: Allows users to specify a fixed integer seed. - **Raster Order (`-r`)**: Unrandomized sequential patch layout. 4. **Automated Unit Testing**: - Add unit tests in `src-tauri/src/commands.rs` verifying that `build_printtarg_args` includes `-R <seed>` or `-r` flags correctly.
gronod added the Kind/BugKind/Enhancement
Reviewed
Confirmed
1
Priority
High
2
labels 2026-08-31 17:54:25 +01:00
Sign in to join this conversation.