OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.09k stars 195 forks source link

AirPrint: object has offset 0 #321

Closed TomKyblik closed 2 years ago

TomKyblik commented 2 years ago

I recently bought Brother DCP-T425W which is Mopria certified, but is not AirPrint certified (unfortunately). I have some RaspberryPis with OSMC at home so I decided to try it via CUPS

=  wlan0 IPv4 Brother DCP-T425W @ osmc-loznice              Internet Printer     local
   hostname = [osmc-loznice.local]
   address = [192.168.2.4]
   port = [631]
   txt = ["printer-type=0x104E" "printer-state=3" "Copies=T" "Color=T" "TLS=1.2" "UUID=3bb03c84-2cc9-3137-6148-5540a350ec70" "URF=DM3" "pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/pwg-raster,image/urf" "product=(DCP-T425W)" "priority=0" "note=Adel" "adminurl=https://osmc-loznice.local.:631/printers/Brother_DCP-T425W" "ty=DCP-T425W - IPP Everywhere" "rp=printers/Brother_DCP-T425W" "qtotal=1" "txtvers=1"]

Printing via CUPS to this printer works OK from Android and Windows -- no errors in /var/log/cups/error_log, but when printing from any iOS device (15.x) there's always a message "Check printer for errors" | Cancel / Continue However when selecting Continue, the printer prints the document/photo just fine

IMG_7264

and /var/log/cups/error_log has entries like this:

W [06/Jan/2022:13:29:12 +0100] [Job 20] /var/spool/cups/d00020-001 (object 8 0): object has offset 0
W [06/Jan/2022:13:29:12 +0100] [Job 20] /var/spool/cups/d00020-001 (object 11 0): object has offset 0
W [06/Jan/2022:13:29:12 +0100] [Job 20] /var/spool/cups/d00020-001 (object 14 0): object has offset 0
W [06/Jan/2022:13:29:12 +0100] [Job 20] /var/spool/cups/d00020-001 (object 17 0): object has offset 0
W [06/Jan/2022:13:48:08 +0100] [Job 21] /var/spool/cups/d00021-001 (object 8 0): object has offset 0
W [06/Jan/2022:13:48:08 +0100] [Job 21] /var/spool/cups/d00021-001 (object 11 0): object has offset 0
W [06/Jan/2022:13:48:08 +0100] [Job 21] /var/spool/cups/d00021-001 (object 14 0): object has offset 0
W [06/Jan/2022:13:48:08 +0100] [Job 21] /var/spool/cups/d00021-001 (object 17 0): object has offset 0
W [06/Jan/2022:13:52:08 +0100] [Job 22] /var/spool/cups/d00022-001 (object 8 0): object has offset 0
W [06/Jan/2022:13:52:08 +0100] [Job 22] /var/spool/cups/d00022-001 (object 11 0): object has offset 0
W [06/Jan/2022:13:52:08 +0100] [Job 22] /var/spool/cups/d00022-001 (object 14 0): object has offset 0
W [06/Jan/2022:13:52:08 +0100] [Job 22] /var/spool/cups/d00022-001 (object 17 0): object has offset 0

OSMC system is based on Debian Buster with CUPS version 2.2.10, however I tried the same with the most recent version on VirtualBox with Ubuntu (CUPS 2.3.3op2-7ubuntu2) and the result is always the same: object has offset 0 is written to logs...

If ipptool output could help: ipptool -tv ipp://Brother-DCP-T425W.local:631/ipp/print get-printer-attributes.test

"/usr/share/cups/ipptool/get-printer-attributes.test":
    Get-Printer-Attributes:
        attributes-charset (charset) = utf-8
        attributes-natural-language (naturalLanguage) = en
        printer-uri (uri) = ipp://Brother-DCP-T425W.local:631/ipp/print
    Get printer attributes using Get-Printer-Attributes                  [PASS]
        RECEIVED: 8068 bytes in response
        status-code = successful-ok (successful-ok)
        attributes-charset (charset) = utf-8
        attributes-natural-language (naturalLanguage) = en
        copies-default (integer) = 1
        finishings-default (enum) = none
        media-default (keyword) = iso_a4_210x297mm
        media-col-default (collection) = {media-type=stationery media-size={x-dimension=21000 y-dimension=29700} media-bottom-margin=300 media-left-margin=300 media-right-margin=300 media-top-margin=300 media-source=auto media-source-properties={media-source-feed-direction=short-edge-first media-source-feed-orientation=3}}
        orientation-requested-default (enum) = portrait
        output-bin-default (keyword) = face-up
        print-quality-default (enum) = normal
        printer-resolution-default (resolution) = 600dpi
        sides-default (keyword) = one-sided
        print-color-mode-default (keyword) = color
        print-content-optimize-default (keyword) = auto
        print-scaling-default (keyword) = auto
        copies-supported (rangeOfInteger) = 1-99
        finishings-supported (enum) = none
        media-supported (1setOf keyword) = iso_a4_210x297mm,na_letter_8.5x11in,na_executive_7.25x10.5in,iso_a5_148x210mm,iso_a6_105x148mm,na_number-10_4.125x9.5in,iso_dl_110x220mm,iso_c5_162x229mm,na_monarch_3.875x7.5in,na_index-4x6_4x6in,oe_photo-l_3.5x5in,na_5x7_5x7in,na_index-5x8_5x8in,custom_min_88.9x127mm,custom_max_215.9x355.6mm
        media-col-supported (1setOf keyword) = media-type,media-size,media-top-margin,media-left-margin,media-right-margin,media-bottom-margin,media-source,media-source-properties
        orientation-requested-supported (1setOf enum) = portrait,landscape
        output-bin-supported (keyword) = face-up
        print-quality-supported (1setOf enum) = normal,high,draft
        printer-resolution-supported (resolution) = 600dpi
        sides-supported (keyword) = one-sided
        print-color-mode-supported (1setOf keyword) = auto,color,monochrome,auto-monochrome
        print-content-optimize-supported (keyword) = auto
        print-scaling-supported (1setOf keyword) = auto,auto-fit,fill,fit,none
        generated-natural-language-supported (1setOf naturalLanguage) = en,cs,hu,pl,bg,ro,sk,hr,sl
        printer-uri-supported (1setOf uri) = ipp://Brother-DCP-T425W.local./ipp/print,ipps://Brother-DCP-T425W.local.:443/ipp/print
        uri-security-supported (1setOf keyword) = none,tls
        uri-authentication-supported (1setOf keyword) = none,none
        printer-name (nameWithoutLanguage) = Brother-DCP-T425W
        printer-location (textWithoutLanguage) =
        printer-info (textWithoutLanguage) = Brother-DCP-T425W
        printer-make-and-model (textWithoutLanguage) = Brother DCP-T425W
        printer-state (enum) = idle
        printer-state-reasons (keyword) = none
        ipp-versions-supported (1setOf keyword) = 1.0,1.1,2.0
        operations-supported (1setOf enum) = Print-Job,Validate-Job,Create-Job,Send-Document,Cancel-Job,Get-Job-Attributes,Get-Jobs,Get-Printer-Attributes,Close-Job,Identify-Printer
        multiple-document-jobs-supported (boolean) = false
        multiple-operation-time-out (integer) = 150
        natural-language-configured (naturalLanguage) = en
        charset-configured (charset) = utf-8
        charset-supported (charset) = utf-8
        document-format-supported (1setOf mimeMediaType) = application/octet-stream,image/pwg-raster,application/vnd.brother-hbp
        document-format-default (mimeMediaType) = application/octet-stream
        printer-is-accepting-jobs (boolean) = true
        queued-job-count (integer) = 0
        pdl-override-supported (keyword) = attempted
        printer-up-time (integer) = 3421
        compression-supported (1setOf keyword) = none,gzip
        color-supported (boolean) = true
        job-creation-attributes-supported (1setOf keyword) = copies,finishings,ipp-attribute-fidelity,job-name,media,media-col,orientation-requested,output-bin,output-mode,print-quality,printer-resolution,requesting-user-name,sides,print-color-mode
        media-bottom-margin-supported (1setOf integer) = 300,0,1200,1200
        media-left-margin-supported (1setOf integer) = 300,0,300,300
        media-right-margin-supported (1setOf integer) = 300,0,300,300
        media-source-supported (1setOf keyword) = auto,main
        media-top-margin-supported (1setOf integer) = 300,0,1200,1200
        media-type-supported (1setOf keyword) = stationery,photographic-glossy,stationery-inkjet,com.brother-bp71
        media-size-supported (1setOf collection) = {x-dimension=21000 y-dimension=29700},{x-dimension=21590 y-dimension=27940},{x-dimension=18415 y-dimension=26670},{x-dimension=14800 y-dimension=21000},{x-dimension=10500 y-dimension=14800},{x-dimension=10477 y-dimension=24130},{x-dimension=11000 y-dimension=22000},{x-dimension=16200 y-dimension=22900},{x-dimension=9842 y-dimension=19050},{x-dimension=10160 y-dimension=15240},{x-dimension=8890 y-dimension=12700},{x-dimension=12700 y-dimension=17780},{x-dimension=12700 y-dimension=20320},{x-dimension=8890-21590 y-dimension=12700-35560}
        pages-per-minute (integer) = 28
        pages-per-minute-color (integer) = 11
        printer-alert (octetString) = code=other
        printer-alert-description (textWithoutLanguage) = Ready
        printer-device-id (textWithoutLanguage) = MFG:Brother;CMD:HBP,PJL;MDL:DCP-T425W;CLS:PRINTER;CID:Brother Generic Jpeg Type2;
        printer-icons (1setOf uri) = http://Brother-DCP-T425W.local./icons/device-icons-128.png,http://Brother-DCP-T425W.local./icons/device-icons-512.png
        printer-more-info (uri) = http://Brother-DCP-T425W.local./
        printer-uuid (uri) = urn:uuid:e3248000-80ce-11db-8000-5c61991a88c6
        job-impressions-supported (rangeOfInteger) = 1-999
        printer-geo-location (unknown) = unknown
        printer-supply-info-uri (uri) = http://Brother-DCP-T425W.local.
        media-ready (keyword) = iso_a4_210x297mm
        media-col-ready (1setOf collection) = {media-type=stationery media-size={x-dimension=21000 y-dimension=29700} media-bottom-margin=300 media-left-margin=300 media-right-margin=300 media-top-margin=300 media-source=main media-source-properties={media-source-feed-direction=short-edge-first media-source-feed-orientation=3}},{media-type=stationery media-size={x-dimension=21000 y-dimension=29700} media-bottom-margin=0 media-left-margin=0 media-right-margin=0 media-top-margin=0 media-source=main media-source-properties={media-source-feed-direction=short-edge-first media-source-feed-orientation=3}}
        identify-actions-supported (keyword) = display
        ipp-features-supported (keyword) = none
        printer-input-tray (1setOf octetString) = type=other;mediafeed=296926;mediaxfeed=209973;maxcapacity=150;level=-2;status=0;name=AUTO;index=1;dimunit=micrometers;unit=sheets;medianame=REGULAR;mediaweight=-2;mediatype=stationery;mediacolor=Unknown;,type=sheetFeedAutoNonRemovableTray;mediafeed=296926;mediaxfeed=209973;maxcapacity=150;level=-2;status=0;name=TRAY1;index=2;dimunit=micrometers;unit=sheets;medianame=REGULAR;mediaweight=-2;mediatype=stationery;mediacolor=Unknown;
        printer-output-tray (octetString) = type=unRemovableBin;maxcapacity=50;remaining=-2;status=0;name=face-up;index=1;unit=sheets;stackingorder=lastToFirst;pagedelivery=faceUp;offsetstacking=notPresent;
        document-format-varying-attributes (keyword) = copies
        multiple-operation-time-out-action (keyword) = abort-job
        printer-organization (textWithoutLanguage) =
        printer-organizational-unit (textWithoutLanguage) =
        printer-get-attributes-supported (keyword) = document-format
        which-jobs-supported (1setOf keyword) = completed,not_completed
        printer-current-time (dateTime) = 2022-01-06T13:47:20Z
        printer-config-change-time (integer) = 1
        printer-config-change-date-time (dateTime) = 2022-01-06T13:50:44Z
        printer-state-change-time (integer) = 1
        printer-state-change-date-time (dateTime) = 2022-01-06T13:50:44Z
        printer-strings-languages-supported (1setOf naturalLanguage) = en,ja
        printer-strings-uri (uri) = http://Brother-DCP-T425W.local./ipp/strings/dict/en.txt
        printer-mandatory-job-attributes (1setOf keyword) = attributes-charset,attributes-natural-language,printer-uri
        marker-colors (1setOf nameWithoutLanguage) = #FF00FF,#00FFFF,#FFFF00,#000000
        marker-high-levels (1setOf integer) = 100,100,100,100
        marker-levels (1setOf integer) = -2,-2,-2,-2
        marker-low-levels (1setOf integer) = 1,1,1,1
        marker-names (1setOf nameWithoutLanguage) = M,C,Y,BK
        marker-types (1setOf keyword) = ink-cartridge,ink-cartridge,ink-cartridge,ink-cartridge
        pdf-versions-supported (keyword) = none
        printer-dns-sd-name (nameWithoutLanguage) = Brother-DCP-T425W
        printer-kind (1setOf keyword) = document,envelope,postcard,photo
        job-pages-per-set-supported (boolean) = false
        mopria-certified (textWithoutLanguage) = 2.0
        pwg-raster-document-resolution-supported (1setOf resolution) = 600dpi,300dpi
        pwg-raster-document-sheet-back (keyword) = rotated
        pwg-raster-document-type-supported (1setOf keyword) = sgray_8,srgb_8
michaelrsweet commented 2 years ago

@TomKyblik Those messages indicate issues in the PDF file you are printing. As for the printer attributes, it certainly looks like the printer has most of everything needed for AirPrint - might just be a testing issue they haven't gone through?

Have you checked for a firmware update for the printer?

TomKyblik commented 2 years ago

@michaelrsweet

Those messages indicate issues in the PDF file you are printing.

It happens while printing mail from Outlook, picture from gallery or web page from Safari, but other systems like Win or Android can print via same CUPS server with no errors reported, so might be after all an issue in iOS itself. If you think it's not a CUPS problem, please feel free to close the issue

Have you checked for a firmware update for the printer?

Firmware is the most recent one. As native AirPrint support is concerned, situation is a bit shady -- some sellers are (were) advertising it with AirPrint support, some don't. I've contancted Brother support and they confirmed to me that this model is not AirPrint capable... Maybe with some future firmware? Anyway thanks...

michaelrsweet commented 2 years ago

@TomKyblik It would be useful to have a few example PDF files from your Raspberry Pi - the printer itself doesn't support PDF or Apple Raster, so the filter error is coming from the 'Pi.

TomKyblik commented 2 years ago

@michaelrsweet I'm not sure what PDF you mean? If I print e.g. an e-mail from iPhone via CUPS, does it get converted to PDF first? I can only see some control files (e.g. c00023) and data files (d00023-001) in /var/spool/cups.

cat c00023
Gattributes-charsetutf-8Httributes-natural-languagecs-czE
                                                                 printer-uri9ipps://osmc-loznice.local.:631/printers/Brother_DCP-T425WBjob-originating-user-namemobilejob-nameOutlook!copies4      media-colJ
media-size4J
            x-dimension!J
print-qualityDsides  one-sided!ion!t7Jmedia-right-margin!,Jmedia-left-margin!,Jmedia-top-margin!�Jmedia-bottom-margin!�7#
192.168.2.1411date-time-at-completed-priority2job-uuid-urn:uuid:bcbf0ab4-3d11-3fd3-77c9-443d33b9c809Bjob-originating-host-name
+!+1date-time-at-creation           �
++1date-time-at-processing
++!time-at-completeda��!time-at-creationa���!time-at-processinga���!job-id#  job-stateDjob-state-reasonsjob-canceled-by-user!job-impressions-completed!job-media-sheets-completedEjob-printer-uri1ipp://osmc-loznice:631/printers/Brother_DCP-T425W!
                                                       job-k-octets/Djob-hold-untilno-holdB
job-sheetsnoneBnoneIdocument-format-suppliedapplication/pdfIdocument-formatapplication/pdfAjob-printer-state-message=/var/spool/cups/d00023-001 (object 14 0): object has offset 0Djob-printer-state-reasonsnone

Edit: holy s**t, the data file is in fact a PDF -- should I upload one or two directly here?

TomKyblik commented 2 years ago

The warning in iPhone appears always, even when printing a picture from gallery, however offset warning is written to logs only when printing text/mail/web page that gets converted to PDF, but when printing pictures, no warning in error_log, but still warning on iPhone... I'm confused now.

debiantriage commented 2 years ago

@TomKyblik object has offset 0 originates from qpdf, wich is used by cups-filters. It is a warning.

Please give (as root) the results of

grep cupsFilter2 /etc/cups/ppd/EVERYWHERE_PPD_FOR_DCP-T425W

and

cupsfilter -p /etc/cups/ppd/EVERYWHERE_PPD_FOR_DCP-T425W -m printer/foo -e --list-filters PPD

PPD could be the previous data file.

TomKyblik commented 2 years ago

@debiantriage

sudo grep cupsFilter2 /etc/cups/ppd/Brother_DCP-T425W.ppd
*cupsFilter2: "image/pwg-raster image/pwg-raster 100 -"
sudo cupsfilter -p /etc/cups/ppd/Brother_DCP-T425W.ppd -m printer/foo -e --list-filters /var/spool/cups/d00026-001

pdftopdf
gstoraster
filipkowicz commented 2 years ago

same issue here, one more thing is that i think driver was added to Airprint only recently BC as i remember few moths ago i wasn't able to add printer at all. now it went smoothly.

michaelrsweet commented 2 years ago

@TomKyblik The PDF file would be the "d" file in the spool directory. Since the CUPS server can't take the HEIF image files from an iOS device directly (and given the patent minefield for HEVC that seems unlikely to change for the foreseeable future) the iOS device will send PDF instead.

zdohnal commented 2 years ago

No response from the reporter for almost 2 months, closing the issue.

prnake commented 2 years ago

same problem, I think it's a new bug in latest 2.3

Wqrld commented 2 years ago

can confirm, i can print perfectly fine from windows etc, but the ipad just doesn't print.

kmorber commented 2 years ago

Same problem here!

zdohnal commented 2 years ago

@prnake , @Wqrld , @kmorber - the current OpenPrinting CUPS version is 2.4.2 - do you use OpenPrinting CUPS or Apple CUPS?

TomKyblik commented 2 years ago

@zdohnal On RasPi it's Apple version 2.2.10 but I also tried the OpenPrinting 2.4.2 on Ubuntu via snap (as official package is 2.4.1) and the result is still the same...

zdohnal commented 2 years ago

Ok, IIUC correctly your setup:

You have some client machine, RaspPi acting as print server and printer.

So it would be great if you tried the following (all with OpenPrinting CUPS):

  1. start CUPS debug logging for both OpenPrinting CUPS instances on client and server - $ cupsctl --debug-logging
  2. pass the pdf you want to print to RasPI, and sent it to the queue on RasPI with lp - $ lp -d <queue_name_on_raspi> <file>
  3. have a OpenPrinting CUPS client (Linux OS machine of your choice with classic RPM/DEB CUPS package, or snapped OpenPrinting CUPS) and send the pdf to destination on RasPi, which is running on OpenPrinting CUPS - $ lp -d <local_queue> <file>

Then please take your /var/log/cups/error_log from both machines, add .txt suffix and upload them here as files in comment.

Does one of them or both trigger the same issue you have when you print from the application on MacOS?

If it doesn't, then there will a trigger in the file which is copied from Apple application, and we will need the d file from /var/spool/cups for the job you've sent via MacOS application to OpenPrinting CUPS client on your local machine.

TomKyblik commented 2 years ago

Let me clarify: My main print server is running on RaspberryPi with OSMC (which is based on Debian Buster at the moment) and CUPS 2.1.10 (the Apple version). As you asked guys having similar issue like I do whether the problem still exists with OpenPrinting CUPS 2.4.2, I've setup a testing print server on Ubuntu 22.04 using CUPS 2.4.2 provided via snap package (as classic Ubuntu package is still 2.4.1) and the warning/error is still the same on iOS/iPadOS... The document gets printed just fine if you say Continue ("Pokračovat" -- "Zrušit" is for Cancel)

obrazek

Now my main printing clients are iOS/iPadOS devices -- my phone, my daughters phones or iPad (all updated to the most recent stable versions available). So I don't use any traditional CUPS client as such (no idea how Apple handles that under the hood).

So only thing I can do is start CUPS 2.4.2 print server with debug logging on Ubuntu and provide the debug logs from server, but I can't do so for clients on iOS/iPadOS.

zdohnal commented 2 years ago

@TomKyblik would you be able to copy the pdf into RasberryPi, log into it and print it from there? I don't have any MacOS device so first I would like to find out whether the issue can be triggered only with OpenPRinting CUPS, or do I have to have MacOS devices for this...

Babyyoda777 commented 2 years ago

Having same issue all of a sudden, was working fine previously tho, happened after reinstalling cups. Any way to downgrade?

/var/spool/cups/d00002-001 (object 12 0): object has offset 0

zdohnal commented 2 years ago

@Babyyoda777 do you have the same network topology as @TomKyblik , MacOS clients + Linux server sharing the printer? Are you using OpenPrinting CUPS?

@TomKyblik any luck trying to log into RasPI, copying the pdf there and printing directly from the server, without Mac clients?

In any case, it would be great if any of you enabled CUPS debug logging on both machines by cupsctl --debug-logging, tried to print the file you have problems with and attached the original PDF which you want to print from Mac, the dXXXXX-XXX file from /var/spool/cups on the server and /var/log/cups/error_log from both machines.

zdohnal commented 2 years ago

Any file can be attached to a github comment once it has .txt suffix.

Babyyoda777 commented 2 years ago

@Babyyoda777 do you have the same network topology as @TomKyblik , MacOS clients + Linux server sharing the printer? Are you using OpenPrinting CUPS?

@TomKyblik any luck trying to log into RasPI, copying the pdf there and printing directly from the server, without Mac clients?

In any case, it would be great if any of you enabled CUPS debug logging on both machines by cupsctl --debug-logging, tried to print the file you have problems with and attached the original PDF which you want to print from Mac, the dXXXXX-XXX file from /var/spool/cups on the server and /var/log/cups/error_log from both machines.

Yes to everything basically, the pdf prints fine when connected directly via usb to the printer but then using AirPrint via Cups on a rpi this error come up on both iPhones and Macs. Printing via usb on a Mac is fine. The AirPrint is being shared over network via a rpi, yes. I will try upload a log soon.

zdohnal commented 2 years ago

@Babyyoda777 and printing via USB on RPi? Meaning send pdf to RPi via scp or similar tool, log into RPi and do lp -d <printer> <pdf>?

Babyyoda777 commented 2 years ago

@Babyyoda777 and printing via USB on RPi? Meaning send pdf to RPi via scp or similar tool, log into RPi and do lp -d <printer> <pdf>?

USB printing is also fine from RPI. I didn't do the log tho.

zdohnal commented 2 years ago

@Babyyoda777 ok, so the issue is really triggered only by PDF coming from Mac.

It would be great if you attached:

Thank you in advance!

cvandesande commented 2 years ago

I have a very similar setup (Debian CUPS server, connected to a non-AirPrint printer, permitting AirPrint to work).

I get a similar message from IOS devices, "check printer for errors" however if I don't touch anything the message disappears after 2-3 seconds, and the document prints successfully.

This is the error from the Debian CUPS 2.3.3op2:

W [09/Sep/2022:21:32:29 +0000] [Job 5] /var/spool/cups/d00005-001 (object 6 0): object has offset 0
D [09/Sep/2022:21:32:29 +0000] [Job 5] Set job-printer-state-message to "/var/spool/cups/d00005-001 (object 6 0): object has offset 0", current level=WARN
W [09/Sep/2022:21:32:29 +0000] [Job 5] /var/spool/cups/d00005-001 (object 9 0): object has offset 0
D [09/Sep/2022:21:32:29 +0000] [Job 5] Set job-printer-state-message to "/var/spool/cups/d00005-001 (object 9 0): object has offset 0", current level=WAR

The Apple CUPS log has the same offset 0 message in the log, and you can see it on the printer dialog window while the job is printing.

Attached are 2 CUPS debug logs and the generated PDF: Apple CUPS client from a Macbook Pro Debian CUPS server Apple-CUPS.log.txt Debian-CUPS.log.txt d00005-001.pdf

zdohnal commented 2 years ago

Hi @cvandesande ,

thank you for the files! Now I can see the warning (object 6 0): object has offset 0 in the logs if I print via lp even on Linux (any other PDF viewer generates a copy of the file which does not generate the warnings - lp sends the file as it is), but it does not generate any pop up window or the warning from server is not propagated to the client.

Ad logs - are there different time zones on Mac and Debian? I see a job on Mac at 17:32:31, but Debian has the first log at 21:32:29. Either way, Apple log does not show the start of the job (even if timezones are different), can you provide the full log for the job from Mac?

My guess the window is shown based on notification which cupsd generates (it happens during update_job() once state message is updated to /var/spool/cups/d00005-001 (object 9 0): object has offset 0), however the application receiving the notify evaluates this as an error (AFAIK we don't pass any information about how serious notification is...) - WDYT, @michaelrsweet ?

cvandesande commented 2 years ago

Yes, different time zones. I'm visiting family overseas and setting up their printer :) It also might be the server is GMT and the Macbook is local.

Here's some fresh logs, new document, same error. Like before it does print successfully, so it's a very minor error. Also managed to catch a screenshot of the offset message on the printer dialog window before the job completed.

Debian-CUPS.log.txt Apple-CUPS.log.txt d00001-001.pdf

Screenshot 2022-09-12 at 15 23 01
zdohnal commented 2 years ago

Ok, so based on the logs and PDF file you've provided I see two issues:

1) PDF d00001-001.pdf produced by macOS Version 12.5.1 (Build 21G83) Quartz PDFContext has an incorrect reference table - it shows null references to non-existing objects in PDF. QPDF (via pdftopdf filter) on Debian complains about the sixth and ninth objects in PDF:

/usr/lib/cups/filter/pdftopdf 1 zdohnal '' 1 '' d00001-001.pdf > out.pdf
...
WARNING: d00001-001.pdf (object 6 0): object has offset 0
WARNING: d00001-001.pdf (object 9 0): object has offset 0

If you check it in xref table in PDF, you see the following records (I've added object numbers to make it more readable):

xref
0 44
0000000000 65535 f 
0000003432 00000 n  - object 1 0
0000011806 00000 n  - object 2 0
0000000022 00000 n  - object 3 0
0000003551 00000 n  - object 4 0
0000007811 00000 n  - object 5 0
0000000000 00000 n  - object 6 0
0000018480 00000 n  - object 7 0
0000010560 00000 n  - object 8 0
0000000000 00000 n  - object 9 0
...

as you can see the objects exist in the xref table, but their addresses are 0 and there are no such objects in the PDF at all. According the PDF tutorials I've read the xref table must contain only objects which are in the PDF, so IMHO it is a bug in Quartz PDFContent (maybe it is PDF generator as cairo is in Linux?), especially since the same objects are missing and are defined empty in xref table in the other PDF file you've supplied - looks like MacOS PDF generator is putting the same empty references to all PDFs sent for printing...

2) There is an IPP client called PrinterProxy, which interprets the message /var/spool/cups/d00005-001 (object 9 0): object has offset 0 incorrectly as an error instead of warning (that's the level of importance on Debian) or info (the level of importance when the message got from Debian to Mac).

Here you can see the beginning of the connection (proof it is some PrinterProxy on Mac):

D [12/Sep/2022:15:14:39 -0400] [Client 22] Server address is "/private/var/run/cupsd".
D [12/Sep/2022:15:14:39 -0400] [Client 22] Accepted from localhost (Domain PrinterProxy[1659])
D [12/Sep/2022:15:14:39 -0400] [Client 22] Waiting for request.
D [12/Sep/2022:15:14:39 -0400] [Client 22] POST / HTTP/1.1

Then this PrinterProxy sends IPP Get-Printer-Attributes (for the printer where the job was sent) and Get-Jobs requests to cupsd every several seconds (this looks random - once it sends both requests several times in a second, then it waits for a second or 4, then sends both requests, wait 1s, then it sends only Get-Printer-Attributes...), f.e.:

...
D [12/Sep/2022:15:14:50 -0400] [Client 22] No authentication data provided.
D [12/Sep/2022:15:14:50 -0400] [Client 22] 2.0 Get-Printer-Attributes 14
D [12/Sep/2022:15:14:50 -0400] Get-Printer-Attributes ipp://localhost:631/printers/Brother_MFC_7460DN___yul_bing
D [12/Sep/2022:15:14:50 -0400] [Client 22] Returning IPP successful-ok for Get-Printer-Attributes (ipp://localhost:631/printers/Brother_MFC_7460DN___yul_bing) from localhost.
...
D [12/Sep/2022:15:14:50 -0400] [Client 22] No authentication data provided.
D [12/Sep/2022:15:14:50 -0400] [Client 22] 2.0 Get-Jobs 15
D [12/Sep/2022:15:14:50 -0400] Get-Jobs ipp://localhost:631/printers/Brother_MFC_7460DN___yul_bing
...

With this cadence of requests, PrinterProxy is able to catch the changed printer's state message for the local printer, which contains the message /var/spool/cups/d00005-001 (object 9 0): object has offset 0. The message gets there from the server via the following steps:

==============================================================

To sum it up, neither of those two issues are CUPS fault - PDF generator from Mac generates incorrect xref table and fixing it would solve both issues, PrinterProxy should verify whether the state message it receives is really an error and report it accordingly (in this case only as info pop-up...)

zdohnal commented 1 year ago

Since there was a misunderstanding in #618 about this issue, I'll comment it plainly here as well:

Those two issues mentioned in summary are (IMHO) bugs in MacOS, which would be great if Apple fixed. In case someone hits the issue, do contact your Apple support and ask them to fix those issues.

adrianschneider94 commented 1 year ago

I opened an issue with Apple, but I'm not sure how high the probability is that it'll be fixed soon.

Is there maybe an approach to silence these misinterpreted warnings/errors until Apple fixes it? What code portions should I look into to do that?

zdohnal commented 1 year ago

The warning comes from libqpdf from QPDF project https://github.com/qpdf/qpdf/ , which is used during implementation of pdftopdf filter. You can try contacting its upstream. Or try to change a PrinterProxy configuration - it might have some settings which can turn off those notifications, but idk - I don't have Mac.

Fluxxo commented 1 year ago

Wanted to chime in here. While I understand it's not CUPS' fault and a violation of the PDFs standards by Apple, it still renders CUPS useless for me as I am 100% running on apple devices.

FYI, I'm running CUPS on docker, so this is a minimal-invasive operation.

1) Check out qlib source code 2) modify $codeDir/libqpdf/QPDF.cc and look for the "offset 0" line. Comment out the three lines:

//warn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(), // this->m->last_object_description, 0, // "MY object has offset 0"));

Run ./configure && make && make install

Finally, you need to figure out where the libqpdf.so.28* files are originally located and symlink into these destinations.

After I did it, everything works nicely. Since it's only a warning, I believe it's fair to ignore it until Apple decides to stick to the standards. I'm also looking into the cupersfilter pdftopdf to understand if the warning can be switched off, since I believe it would be the cleanest approach, but I've tried to tamper around with the cups filters and build a wrapper, yada yada yada... Nothing worked.

whyidie commented 1 year ago

Was having same object offset 0 error, but unlike OP I did not get dialogue box and was unable to print effected documents. Stumbled across this post installed qpdf and while I still get the error, at least I'm printing :

https://github.com/pdewacht/brlaser/issues/49#issuecomment-898800199 # # #