Menu ▾ ▴

#766 Canon multiraster: final complete block is not written

5.3-fixed
closed-accepted
nobody
5
17 hours ago
2 days ago
No

Affected source

src/main/print-canon.c, canon_write_multiraster().
Confirmed in Debian Gutenprint 5.3.4.20220624T01008808d602-4 and official
master 76b0f3571a1cf3d07fe9068e87840be94d28df5a.
Observed hardware: Canon iP4600, bjc-iP4600-series, Debian 13 ARM64.

Cause

Complete blocks are written at the beginning of the next block. At the
last raster line there is no next block, but the final flush is conditional
on pd->out_height % raster_lines_per_block being nonzero. Therefore, a
height exactly divisible by the block size loses its final block.

For 16-line blocks, 6816 input rows produce 425 blocks (6800 rows) instead
of 426 blocks (6816 rows). Heights 16 and 32 similarly produce 0 and 1
blocks respectively. This is observable offline, before any USB transfer.

Minimal fix

Always write the final buffered block. Pad only partial final blocks, using:

int missing = (raster_lines_per_block -
               (pd->out_height % raster_lines_per_block)) % raster_lines_per_block;

The attached patch preserves the existing per-channel block-writing path
and padding behavior. It does not change printer initialization, media
selection, page eject/job-end commands or the USB backend.

Regression tests

test_multiraster_flush.py extracts the actual upstream function and
compiles it with compressor/writer stubs. It checks ordered rows and block
counts for all four channels at heights 1, 15, 16, 17, 32, 6816 and 6817.

On reviewed unmodified master, 16, 32 and 6816 fail; the four partial-block
cases pass. With the patch all seven cases pass. Requires Python 3 and a
C99 compiler, not a printer or CUPS installation.

CANON_SOURCE="$PWD/src/main/print-canon.c" python3 /path/to/test_multiraster_flush.py -v

Hardware observation and scope

With the same correction in the Debian driver, the formerly missing
bottom test-page frame appeared on paper and the user confirmed all four
borders. A separate earlier A4/Letter mismatch in our comparison runner
had already been corrected before isolating this final-block defect.
Neither that runner error nor unresolved USB stalls are attributed to
this patch. Current master has been regression-tested offline, not newly
built and physically printed in this report.

Ticket #681 mentioned a
missing last CUPS test-page line on a Canon MG7500-series printer, alongside
other border and borderless issues. It was closed as out-of-date in 2024.
Those broader margin symptoms are not proven to share this cause, and no
MG7500 hardware has been tested here. The present report isolates a
deterministic final-block loss independently of media margins and CUPS.

Attachments: 02-canon-multiraster-final-block.patch, test_multiraster_flush.py.

2 Attachments

Discussion

  • Solomon Peachy

    Solomon Peachy - 17 hours ago
    • Description has changed:

    Diff:

    
    
    • status: open --> closed-accepted
    • Group: --> 5.3-fixed
    • Priority: --> 5
     
  • Solomon Peachy

    Solomon Peachy - 17 hours ago

    Committed as 79d9332ced.

     

Log in to post a comment.