Closed Bug 1712555 Opened 4 years ago Closed 3 years ago

Printing doesn't work in the Flatpak version of Firefox

Categories

(Core :: Widget: Gtk, defect)

Unspecified
Linux
defect

Tracking

()

VERIFIED FIXED
99 Branch
Tracking Status
firefox98 --- verified
firefox99 --- fixed

People

(Reporter: bleisebastian780, Assigned: jhorak)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 1 obsolete file)

Attached file Printing bug

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

I have opened a pdf with firefox and wanted to print it out.

Actual results:

Nothing was printed and I did not receive an error message.

Expected results:

Actually he should have printed

The Bugbug bot thinks this bug should belong to the 'Core::Printing: Output' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Printing: Output
Product: Firefox → Core

Thanks for reporting this!
When you try to print, does the print dialog appear at all? Does printing to PDF work?

Flags: needinfo?(bleisebastian780)

Yes the print dialog appears and I can select a printer. When I press the print button, the dialog closes and nothing happens.
Printing in a PDF document works.

Flags: needinfo?(bleisebastian780)

Can you try a standard Firefox build (e.g. from https://www.mozilla.org/en-US/firefox/browsers/) rather than a flatpak-packaged version with the same system and printer? It would be useful to know if it is specifically the flatpak environment that is the problem here.

Flags: needinfo?(bleisebastian780)

I downloaded firefox from your link as a TAR, unpacked and started it and it prints perfectly.
I also tested ungoogle-chomium as fltpak and it also prints.
It is only the flatpak from firefox that does not print.

Flags: needinfo?(bleisebastian780)

Thanks for testing, that's useful to know.

Blocks: flatpak

Seems like a pretty serious flaw in the flatpak Firefox configuration, but as that's not our primary distribution method at this point (AFAIK), I guess that makes it less critical for now.

Severity: -- → S3

Re-tested and this bug still exists in flatpak Firefox 91.0 as described. Anything I can test against this to shine more light on it?

Same problem here. Firefox 94 with Flatpak.
Using Debian 11, Gnome 3.38, Flatpak last version.
No way to print. Even if in Flatseal permissions, the Socket CUPS is enabled.

Please fix. Thanks!

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Linux
Summary: Dosn't Printing PDF (flatpak) → Printing doesn't work in the Flatpak version of Firefox
Version: Firefox 88 → Trunk

Part of the problem is in the freedesktop runtime's GTK which does not use the cups print backend module. The only options for the printers are "Print to LPR" and "Print to file" when enumerating printers[1]. This is not a case for the fedora runtime where the printing works.

It seems that the Firefox code is mixing two approaches to the printing:

  1. it directly asks cups for the printer lists to populate printers in Print dialog
  2. it uses gtk_print_job_new to start the printing task.

Since the gtk is missing cups backend the print name obtained from cups is not found in the gtk printer enumeration.

Currently the print portal we're trying to use is not working properly with the non system Firefox print dialog [2]. We should only use cups or make the cups gtk print backend available in the runtime.

from flatpak run org.freedesktop.Sdk//20.08
./usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends
./usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends/libprintbackend-file.so
./usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends/libprintbackend-lpr.so

flatpak run org.fedoraproject.Sdk
[📦 org.fedoraproject.Sdk gtk-3.0]$ find /|grep printbackends
find: ‘/proc/tty/driver’: Permission denied
/usr/lib64/gtk-2.0/2.10.0/printbackends
/usr/lib64/gtk-2.0/2.10.0/printbackends/libprintbackend-cups.so
/usr/lib64/gtk-2.0/2.10.0/printbackends/libprintbackend-file.so
/usr/lib64/gtk-2.0/2.10.0/printbackends/libprintbackend-lpr.so
/usr/lib64/gtk-3.0/3.0.0/printbackends
/usr/lib64/gtk-3.0/3.0.0/printbackends/libprintbackend-cups.so
/usr/lib64/gtk-3.0/3.0.0/printbackends/libprintbackend-file.so
/usr/lib64/gtk-3.0/3.0.0/printbackends/libprintbackend-lpr.so
/usr/lib64/gtk-4.0/4.0.0/printbackends
/usr/lib64/gtk-4.0/4.0.0/printbackends/libprintbackend-cloudprint.so
/usr/lib64/gtk-4.0/4.0.0/printbackends/libprintbackend-cups.so
/usr/lib64/gtk-4.0/4.0.0/printbackends/libprintbackend-file.so
flatpak run org.freedesktop.Sdk//21.08
[📦 org.freedesktop.Sdk gtk-3.0]$ find /|grep printbackends
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends/libprintbackend-file.so
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends/libprintbackend-lpr.so

I created issue on the freedesktop: https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1371

[1] https://searchfox.org/mozilla-central/source/widget/gtk/nsDeviceContextSpecG.cpp#247
[2] https://searchfox.org/mozilla-central/source/widget/gtk/nsDeviceContextSpecG.cpp#280

The quickest way to fix this before it will be handled in runtime (eventually) is to build libprintbackend-cups in org.mozilla.firefox.BaseApp. See example from chromium flatpak[0] (which is why chromium isn't affected by this issue as it was reported above)

https://github.com/flathub/org.chromium.Chromium/blob/master/org.chromium.Chromium.yaml#L68-L81

I have submitted a PR to the BaseApp: https://github.com/flathub/org.mozilla.firefox.BaseApp/pull/21

I will merge it soon, and we will be able to test on Friday whether beta version works correctly now.

I just tried 97.0b3 build from FlatHub Beta repo and could not printing output to a CUPS queue. Should I wait for another build to arrive?
Cheers, Joe.

The libprintbackend-cups.so is present in the correct location in the current beta build, so it must be something else this time.

[📦 org.mozilla.firefox ~]$ stat /app/lib/gtkmodules/3.0.0/printbackends/libprintbackend-cups.so 
  File: /app/lib/gtkmodules/3.0.0/printbackends/libprintbackend-cups.so
  Size: 158560    	Blocks: 312        IO Block: 4096   regular file
Device: 23h/35d	Inode: 432063      Links: 3
Access: (0755/-rwxr-xr-x)  Uid: (65534/nfsnobody)   Gid: (65534/nfsnobody)
Access: 2022-01-05 15:55:33.298462740 +0100
Modify: 2022-01-05 15:55:28.257462622 +0100
Change: 2022-01-21 13:45:31.596967277 +0100
 Birth: 2022-01-05 15:55:28.255462622 +0100

Just to be sure tested the 97.0b8 flatpak. Behavior still appears same as described for this bug:
There no error or print notification after print dialog is submitted from Firefox - the print job just disappears.

No job appears in the CUPS queue - which may not mean anything as I have noticed this can happen with other apps, even when printing is successful. The CUPS printing socket is enabled, as is devices = all for the Flatpak (using Flatseal). Print to PDF is working.

Printing using the Print System Dialog also fails in same way.

Yes, it's still the problem:

  1. the backend is installed but not enabled in GtkSettings, the default value is set during runtime build time to GTK_PRINT_BACKENDS which is lpr,file:
    https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtksettings.c#L1009
  2. the /app/lib/gtkmodules is not in env var GTK_PATH, if it is the GTK check following paths:
/app/lib/gtkmodules/3.0.0/x86_64-unknown-linux-gnu/modules
/app/lib/gtkmodules/3.0.0/modules
/app/lib/gtkmodules/x86_64-unknown-linux-gnu/modules
/app/lib/gtkmodules/modules

To load the cups backend I had to add ~/.config/gtk-3.0/settings.ini:

[Settings]
gtk-print-backends = lpr,file,cups

So far I was unable to use /app/etc/gtk-3.0 instead. With that the module is trying to be loaded, in my case it ended by

(firefox:1360): Gtk-WARNING **: 15:38:38.603: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /app/lib/gtkmodules/3.0.0/printbackends/libprintbackend-cups.so)

but that might be my wrong setup.

  1. in order to print from the firefox print dialog the widget.use-xdg-desktop-portal.print must be set to 0, the portal printing is not working ATM.

Perhaps the following fix from chromium is needed for ff as well: https://github.com/flathub/org.chromium.Chromium/blob/master/org.chromium.Chromium.yaml#L83-L89

Also "--env=GTK_PATH=/app/lib/gtkmodules" added to manifest, see https://github.com/flathub/org.chromium.Chromium/blob/master/org.chromium.Chromium.yaml#L11

Assignee: nobody → jhorak
Status: NEW → ASSIGNED

Yes, this is also required, otherwise the module is not loaded. Created a pull request for the BaseApp: https://github.com/flathub/org.mozilla.firefox.BaseApp/pull/22

Added comment to clarify GTK_PATH settings

Depends on D138908

Attachment #9264344 - Attachment is obsolete: true
Pushed by archaeopteryx@coole-files.de: https://hg.mozilla.org/integration/autoland/rev/64662c03fe99 Enable gtk's cups printing backend for flatpak;r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch
Component: Printing: Output → Widget: Gtk
Depends on: 1688720

Could this be backported to stable or beta?

The one change here only affects Flatpak packaging.

The fix is not complete, I'll continue to work on it when the org.mozilla.firefox.BaseApp changes lands. Additional changes needs to be done to the the sources to have it fixed.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

With the Firefox flatpak beta (instructions from: https://bryanquigley.com/posts/mindshare/firefox-beta-via-flatpak.html ) updated org.mozilla.firefox.BaseApp and widget.use-xdg-desktop-portal.print = 0 I'm able to print from the flatpak. when started correctly:
flatpak run --socket=cups --env=GTK_PATH=/app/lib/gtkmodules org.mozilla.firefox//beta

I'm going to remove the print portal from the Firefox sources because it GTK is dealing with it for us.

We no longer need to use the print portal, the gtk is doing that for us
for the system print dialog and the native print dialog uses GtkPrintJob
which sends jobs to the cups print backend.

Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Resolution: --- → FIXED

Would be nice if this could be backported to beta or stable.

Flags: needinfo?(jhorak)

Comment on attachment 9265339 [details]
Bug 1712555 Remove obsolete print portal; r=emilio

Beta/Release Uplift Approval Request

  • User impact if declined: There's no impact because the patch affects only flatpak where it fixes the print problems.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It's code removal of the non functional code, so I expect no risk and adding reqired flatpak permission to allow printing by using cups.
  • String changes made/needed:
Flags: needinfo?(jhorak)
Attachment #9265339 - Flags: approval-mozilla-beta?
Attachment #9264178 - Flags: approval-mozilla-beta?

Comment on attachment 9265339 [details]
Bug 1712555 Remove obsolete print portal; r=emilio

Morphing into a mozilla-release request as our last betas were last week. We have already built our Release Candidate, I am keeping this one on my radar as a ride-along if we have reasons to build a RC2 before shipping 98.

Attachment #9265339 - Flags: approval-mozilla-beta? → approval-mozilla-release?
Attachment #9264178 - Flags: approval-mozilla-beta? → approval-mozilla-release?

Comment on attachment 9265339 [details]
Bug 1712555 Remove obsolete print portal; r=emilio

Approved as ride-along for RC2.

Attachment #9265339 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9264178 - Flags: approval-mozilla-release? → approval-mozilla-release+

Comment on attachment 9265339 [details]
Bug 1712555 Remove obsolete print portal; r=emilio

Then patches don't apply to the release branch.

Attachment #9265339 - Flags: approval-mozilla-release+ → approval-mozilla-release-
Attachment #9264178 - Flags: approval-mozilla-release+ → approval-mozilla-release-

The first patch applies cleanly. Here's a better patch for uplift that doesn't need rebasing the second patch.

Flags: needinfo?(pascalc)
Flags: needinfo?(pascalc)
Attachment #9266077 - Flags: approval-mozilla-release+
Attachment #9264178 - Flags: approval-mozilla-release- → approval-mozilla-release+
QA Whiteboard: [qa-triaged]

Reproduced the issue on Firefox 97.0.1 flatpak on Ubuntu 20.04 with the info provided in Comment 0 and a sample pdf.

The issue is fixed on Firefox 98.0 flatpak on the same machine. Couldn't verify on Firefox 99 as there is no flatpak build available to install afaik.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

This is not working with flatpak v99, in ubuntu (xorg) 22.04
No printers are visible. Printing with system dialog shows only the save pdf option.

When I uninstalled and reinstalled, it worked.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: