Bug 447106

Summary: firefox can't print with xdg desktop portal kde
Product: [Plasma] xdg-desktop-portal-kde Reporter: pmargeti34
Component: generalAssignee: Jan Grulich <jgrulich>
Status: RESOLVED UPSTREAM    
Severity: major CC: adi, nate, nsane457
Priority: NOR    
Version: 5.23.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description pmargeti34 2021-12-17 05:27:03 UTC
I enabled widget.use-xdg-desktop-portal in about:config to use KDE file picker with firefox. With this setting on, printing is impossible from firefox

I tried to print a:

    webpage
    single image
    pdf

Actual results:

Nothing. It didn't print.

Expected results:

It printed.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Archlinux
(available in About System)
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.90
Qt Version: 5.15.2

ADDITIONAL INFORMATION
System print dialogue is also unavailable
disabling  the widget.use-xdg-desktop-portal preference in firefox allows printing and it also shows gnome print dialogue

Link to the firefox bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1746559
Comment 1 Nate Graham 2022-01-18 19:30:37 UTC
What exactly doesn't work?

1. The print dialog doesn't even appear at all when you go to File > Print
2. The print diapog appears, but when you click on its "Print" button, nothing is sent to the printer (its job queue remains empty)
3. A job gets sent to the printer, but it never starts
Comment 2 adi 2022-01-21 08:03:04 UTC
(In reply to Nate Graham from comment #1)
> What exactly doesn't work?
> 
> 1. The print dialog doesn't even appear at all when you go to File > Print
> 2. The print diapog appears, but when you click on its "Print" button,
> nothing is sent to the printer (its job queue remains empty)
> 3. A job gets sent to the printer, but it never starts

For me, the second happens. For the time being, I patched the use of portal printing out of thunderbird and firefox esr. And actually I am not sure whether this is a kde portal issue or a mozilla issue.
I did, however, collect the following from .xsession-errors (this is from firefox-esr on debian/bullseye and it looks identical for thunderbird):
(firefox-esr:7056): GLib-GObject-CRITICAL **: 23:32:51.400: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/plasma/components/Highlight.qml:34:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }
qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 45843, resource id: 14698511, major code: 20 (GetProperty), minor code: 0
xdp-kde-print: Print called with parameters:
xdp-kde-print:     handle:  "/org/freedesktop/portal/desktop/request/1_93/t"
xdp-kde-print:     app_id:  ""
xdp-kde-print:     parent_window:  ""
xdp-kde-print:     title:  "Print"
xdp-kde-print:     fd:  23
xdp-kde-print:     options:  QMap()
xdp-kde-print: Failed to print: no QPrinter what can be used for printing

which seems to relate to https://github.com/KDE/xdg-desktop-portal-kde/blob/master/src/print.cpp#L212.
Comment 3 Bug Janitor Service 2022-02-05 04:37:51 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 adi 2022-02-05 12:26:50 UTC
I think the information reported is complete; I am not sure whether this is a bug in Firefox/Thunderbird with not using portal printing the way it should be used.
Comment 5 nsane457 2022-02-07 18:08:45 UTC
I have the same problem.  With `GTK_USE_PORTAL=1 firefox`, KDE dialogs show up fine but printing fails with:

> xdg-desktop-portal-kde[1583]: xdp-kde-print: Print called with parameters:
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     handle:  "/org/freedesktop/portal/desktop/request/1_125/t"
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     app_id:  ""
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     parent_window:  ""
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     title:  "Print"
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     fd:  18
> xdg-desktop-portal-kde[1583]: xdp-kde-print:     options:  QMap()
> xdg-desktop-portal-kde[1583]: xdp-kde-print: Failed to print: no QPrinter what can be used for printing

 With `GTK_USE_PORTAL=0 firefox`, printing works.

Likely related to https://bugzilla.mozilla.org/show_bug.cgi?id=1746559
Comment 6 pmargeti34 2022-02-08 00:14:06 UTC
(In reply to nsane457 from comment #5)
> I have the same problem.  With `GTK_USE_PORTAL=1 firefox`, KDE dialogs show
> up fine but printing fails with:
> 
> > xdg-desktop-portal-kde[1583]: xdp-kde-print: Print called with parameters:
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     handle:  "/org/freedesktop/portal/desktop/request/1_125/t"
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     app_id:  ""
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     parent_window:  ""
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     title:  "Print"
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     fd:  18
> > xdg-desktop-portal-kde[1583]: xdp-kde-print:     options:  QMap()
> > xdg-desktop-portal-kde[1583]: xdp-kde-print: Failed to print: no QPrinter what can be used for printing
> 
>  With `GTK_USE_PORTAL=0 firefox`, printing works.
> 
> Likely related to https://bugzilla.mozilla.org/show_bug.cgi?id=1746559

It's literally linked in the bug report. So thanks for your +1