You are not logged in.

#1 2021-03-22 15:28:59

brian001
Member
Registered: 2021-01-04
Posts: 31

Firefox printing fails with Brother driver (Perl?)

Today I found that the latest firefox 86.0.1 will not print with my Brother DCP-2540dw. Other programs print fine.

I don't know when this problem started, but the printer driver hasn't been updated for years. https://aur.archlinux.org/packages/brot … 40dw-cups/

I tried rolling back Firefox to version 85 and 84 with fresh profiles but I keep getting the same error.

It looks like Firefox passes custom page dimensions and something in the Brother driver errors out with the Firefox values.

The specific error is:

D [22/Mar/2021:11:14:06 -0400] [Job 488] Can\'t use an undefined value as a subroutine reference at /usr/lib/cups/filter/brother_lpdwrapper_DCPL2540DW line 559.

And here's the warn level error output:

E [22/Mar/2021:11:14:06 -0400] [Job 488] Job stopped due to filter errors; please consult the /var/log/cups/error_log file for details.
D [22/Mar/2021:11:14:06 -0400] [Job 488] The following messages were recorded from 11:14:06 AM to 11:14:06 AM
D [22/Mar/2021:11:14:06 -0400] [Job 488] Applying default options...
D [22/Mar/2021:11:14:06 -0400] [Job 488] Adding start banner page "none".
D [22/Mar/2021:11:14:06 -0400] [Job 488] Adding end banner page "none".
D [22/Mar/2021:11:14:06 -0400] [Job 488] File of type application/pdf queued by "anonymous".
D [22/Mar/2021:11:14:06 -0400] [Job 488] hold_until=0
D [22/Mar/2021:11:14:06 -0400] [Job 488] Queued on "Brother_DCP-L2540DW_series" by "anonymous".
D [22/Mar/2021:11:14:06 -0400] [Job 488] time-at-processing=1616426046
D [22/Mar/2021:11:14:06 -0400] [Job 488] 2 filters for job:
D [22/Mar/2021:11:14:06 -0400] [Job 488] pdftopdf (application/pdf to application/vnd.cups-pdf, cost 66)
D [22/Mar/2021:11:14:06 -0400] [Job 488] brother_lpdwrapper_DCPL2540DW (application/vnd.cups-pdf to printer/Brother_DCP-L2540DW_series, cost 0)
D [22/Mar/2021:11:14:06 -0400] [Job 488] job-sheets=none,none
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[0]="Brother_DCP-L2540DW_series"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[1]="488"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[2]="anonymous"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[3]="Test Page"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[4]="1"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[5]="PageSize=Custom.612.00x792.00 Collate job-uuid=urn:uuid:522c9d9e-1d24-3c53-60f8-d84a9b8581bb job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1616426046 time-at-processing=1616426046"
D [22/Mar/2021:11:14:06 -0400] [Job 488] argv[6]="/var/spool/cups/d00488-001"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[0]="CUPS_CACHEDIR=/var/cache/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[1]="CUPS_DATADIR=/usr/share/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[2]="CUPS_DOCROOT=/usr/share/cups/doc"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[4]="CUPS_REQUESTROOT=/var/spool/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[5]="CUPS_SERVERBIN=/usr/lib/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[6]="CUPS_SERVERROOT=/etc/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[7]="CUPS_STATEDIR=/run/cups"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[8]="HOME=/var/spool/cups/tmp"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[9]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/bin:/bin:/usr/bin"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[10]="SERVER_ADMIN=root@sage"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[11]="SOFTWARE=CUPS/2.3.3op2"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[12]="TMPDIR=/var/spool/cups/tmp"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[13]="USER=root"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[14]="CUPS_MAX_MESSAGE=2047"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[15]="CUPS_SERVER=/run/cups/cups.sock"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[16]="CUPS_ENCRYPTION=IfRequested"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[17]="IPP_PORT=631"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[18]="CHARSET=utf-8"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[19]="LANG=en_US.UTF-8"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[20]="PPD=/etc/cups/ppd/Brother_DCP-L2540DW_series.ppd"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[21]="RIP_MAX_CACHE=128m"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[22]="CONTENT_TYPE=application/pdf"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[23]="DEVICE_URI=lpd://192.168.1.113/queue"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[24]="PRINTER_INFO="
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[25]="PRINTER_LOCATION="
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[26]="PRINTER=Brother_DCP-L2540DW_series"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[27]="PRINTER_STATE_REASONS=none"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[28]="CUPS_FILETYPE=document"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[29]="FINAL_CONTENT_TYPE=application/vnd.cups-pdf"
D [22/Mar/2021:11:14:06 -0400] [Job 488] envp[30]="AUTH_I****"
D [22/Mar/2021:11:14:06 -0400] [Job 488] Started filter /usr/lib/cups/filter/pdftopdf (PID 200044)
D [22/Mar/2021:11:14:06 -0400] [Job 488] Started filter /usr/lib/cups/filter/brother_lpdwrapper_DCPL2540DW (PID 200045)
D [22/Mar/2021:11:14:06 -0400] [Job 488] Started backend /usr/lib/cups/backend/lpd (PID 200046)
D [22/Mar/2021:11:14:06 -0400] [Job 488] STATE: +connecting-to-device
D [22/Mar/2021:11:14:06 -0400] [Job 488] Looking up \"192.168.1.113\"...
D [22/Mar/2021:11:14:06 -0400] [Job 488] STATE: -connecting-to-device
D [22/Mar/2021:11:14:06 -0400] [Job 488] 192.168.1.113=192.168.1.113
D [22/Mar/2021:11:14:06 -0400] [Job 488] backendWaitLoop(snmp_fd=6, addr=0x560cef429808, side_cb=0x560ced71c1d0)
D [22/Mar/2021:11:14:06 -0400] [Job 488] pdftopdf: Last filter determined by the PPD: brother_lpdwrapper_DCPL2540DW; FINAL_CONTENT_TYPE: application/vnd.cups-pdf => pdftopdf will not log pages in page_log.
D [22/Mar/2021:11:14:06 -0400] [Job 488] PDF interactive form and annotation flattening done via QPDF
D [22/Mar/2021:11:14:06 -0400] [Job 488] PID 200044 (/usr/lib/cups/filter/pdftopdf) exited with no errors.
D [22/Mar/2021:11:14:06 -0400] [Job 488] Can\'t use an undefined value as a subroutine reference at /usr/lib/cups/filter/brother_lpdwrapper_DCPL2540DW line 559.
D [22/Mar/2021:11:14:06 -0400] [Job 488] PID 200045 (/usr/lib/cups/filter/brother_lpdwrapper_DCPL2540DW) stopped with status 255 (Unknown error 155)
D [22/Mar/2021:11:14:06 -0400] [Job 488] Hint: Try setting the LogLevel to "debug" to find out more.
D [22/Mar/2021:11:14:06 -0400] [Job 488] PID 200046 (/usr/lib/cups/backend/lpd) exited with no errors.
D [22/Mar/2021:11:14:06 -0400] [Job 488] End of messages
D [22/Mar/2021:11:14:06 -0400] [Job 488] printer-state=3(idle)
D [22/Mar/2021:11:14:06 -0400] [Job 488] printer-state-message="Filter failed"
D [22/Mar/2021:11:14:06 -0400] [Job 488] printer-state-reasons=none

This is the offending line from the printer driver:

	($x , $y) = &$unitfunc ( $psiz[0] ,$psiz[1]);

And here is the function:

sub check_custom_paper {
    my $x = 0;
    my $y = 0;
    my $unitfunc;
    my $unit = '';
    my $ssize = '';

    (my $PPD , my $lpr_options_ref) = @_;

    if ( $lpr_options_ref->{'-pt'} eq "CUSTOM0" ){

	foreach (keys %units){

	    if ( $ppdcust =~ /[0-9]$_$/) {
		logprint( 2 ,   "HIT $_\n");
		$unit = $_;
		$unitfunc = $units{$_};
	    }
	}
	$ssize = $ppdcust;
	$ssize =~ s/^Custom\.//g;
	$ssize =~ s/$unit$//g;


	my @psiz = split (/x/,$ssize);
	($x , $y) = &$unitfunc ( $psiz[0] ,$psiz[1]);

	return ($x , $y);
    }
    elsif ( $lpr_options_ref->{'-pt'} =~  /CUSTOM[1-9]/ ){

	my $tmp = '*PaperDimension '."$lpr_options_ref->{'-pt'}";
	my $ssize = `grep \"$tmp\" $PPD`;
	chomp($ssize);
	$ssize =~ s/\"$//;
	$ssize =~ s/^.*\"//;
	my @psiz = split (/ /,$ssize);
	($x , $y) = &pt2dot ( $psiz[0] ,$psiz[1]);
	return ($x , $y);
    }
    return ("{Undefined}" , "{Undefined}");
}

Here's the full file: https://gist.github.com/brianmercer/a63 … 1ebb257397

Anyone with Perl knowledge who can see a way to fix the problem in the printer driver?

Or any other suggestions?

Last edited by brian001 (2021-03-22 15:36:54)

Offline

#2 2021-03-22 15:58:58

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: Firefox printing fails with Brother driver (Perl?)

Try to add a line like

$unitfunc = $units{"Letter"} if $unitfunc == "";

before the problematic line. Perhaps initialize $unitfunc to "" at the beginning too...

Or maybe use "LT" if "Letter" does not work.

Last edited by Morn (2021-03-22 16:00:38)

Offline

#3 2021-03-22 20:36:13

brian001
Member
Registered: 2021-01-04
Posts: 31

Re: Firefox printing fails with Brother driver (Perl?)

After much trial and error I am using this as a workaround:

        # if no unit indicator in custom size, default to points
        # $unitfunc = \&pt2dot
        if ( $unitfunc == '' ){
                $unitfunc = $units{pt};
        }

I guess it's Firefox's fault for not putting "pt" at the end of the custom size?

Last edited by brian001 (2021-03-22 21:50:21)

Offline

Board footer

Powered by FluxBB