msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.24k stars 1.21k forks source link

GTK2, GTK3 printing still not working properly? #14787

Open asctime opened 1 year ago

asctime commented 1 year ago

Description / Steps to reproduce the issue

In testing, none of these "vanilla"gtk apps when compiled, can actually print: leafpad gedit (from MSYS2 distro with patches) evolution (see https://gitlab.gnome.org/GNOME/evolution/-/blob/master/src/e-util/e-print.c)

Every printing MinGW64-GTK application "that can actually print" seems to use either CAIRO or some win32 native WMF homebrew: inkscape dia evince

Here is a typical example from Leafpad, a barebones GTK text editor: https://github.com/tarot231/leafpad/blob/main/src/gtkprint.c

The result is always the same. Banners, headers etc get printed but never the actual content buffer, so the rest is blank.

Expected behavior

Print full content

Actual behavior

Content Missing

Windows Version

10 Pro

MINGW environments affected

Biswa96 commented 1 year ago

Does any program provided by upstream have that option working?

asctime commented 1 year ago

@Biswa96 apparently so. I downloaded Claws Mail x64 binary and it prints fine.

Compile the source using MinGW64 and I have the same issue again.

Here's their implementation: https://github.com/mrvdb/claws-mail/blob/mrb/master/src/printing.c

PE reports an MSVC+ toolchain for the binary. So that's working.. :(

Biswa96 commented 1 year ago

The repository seem to be archived and last commit was in 2015. Is there any project which is not archived and in proper maintenance?

asctime commented 1 year ago

@Biswa96 Actually I think that's just a mirror. Try this one: https://git.claws-mail.org/?p=claws.git;a=summary

Anyway, it's all beside the point if the functionality doesn't work for MinGW64 anyway, right? In that case we have two choices: go on with broken libraries that people will continue to scratch their head with, or make a note in the README that says ATM its doesn't work and redirect functionality to the GTK file backend etc.

I wasn't sure this was the case, but it sad considering the amount of time and discussion gone into GTK printing support on Windows..

Biswa96 commented 1 year ago

I do not have printer to reproduce the issue. Please wait for others to comment.

lazka commented 1 year ago

I also don't have a printer. Printing to pdf from geany, inkscape and gtk4-demo seems to work fine here at least. The print preview is missing though.

asctime commented 1 year ago

@lazka this is strictly a GTK2 GTK3 bug please use those demos.

Edit: sorry I just saw inkscape in your reply. please re-read OP and look at the code.

From the balcony: Look guys I can see already this is probably a case of "it was always broken nobody ever went deep enough to give a *". All that I ask is please update your official texts for these packages to state st like "printing is broken. dont try. until generous coder x magically appears with the (very) long awaited MINGW fix for this, we have IFDEFd the whole windows print stuff out and opened the field back up to file and cups alternatives. I hear they have actually made progress on windows. "

But please please PLEASE never pretend to have functionality that you actually don't have. It looks bad on date night.

lazka commented 1 year ago

I understand that it's annoying when things that ought to work don't, but this discussion doesn't get us anywhere.

We need to figur out what is broken and file an issue with gtk, or if its related to packaging, then here.

We are not active gtk devs and we just package gtk (mostly) as is.

raedrizqie commented 1 year ago

Printing to pdf on gtk3-demo is also working fine for me

asctime commented 1 year ago

@raedrizqie that works for me as well. I will have to look deeper to see why the demo prints but our gedit (that uses similar code) doesn't (well at least for me). I've been recompiling and refactoring most of the day and I manage to squeeze some text along the edges, so I'm guessing that have a pagesize/margin issue similar to what is discussed upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/396

@lazka it's frustrating because people compile and release stuff without even testing if it works. It's frustrating because it does work on other platforms mentioned above. So the bug is ours. I know what your trying to say, I would counter that burying it won't help anything either.

General update: @raedrizqie thanks for the lead on the gtk3-demo, I actually didn't think about that - interestingly gtk(2)-demo also prints perfectly for me.

giuspen commented 1 year ago

I have a crash when printing ( https://github.com/giuspen/cherrytree/issues/2066 ) which as the backtrace below shows is pointing the finger to libcairo-2.dll calling DWrite.dll:

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffae80b5714 in ?? () from C:\Windows\SYSTEM32\DWrite.dll
(gdb) bt
#0  0x00007ffae80b5714 in ?? () from C:\Windows\SYSTEM32\DWrite.dll
#1  0x00007ffab8371f4c in ?? () from C:\msys64\mingw64\bin\libcairo-2.dll

I suspect this was introduced when re-enabling DWite in https://github.com/msys2/MINGW-packages/commit/853c407a0d62503e7db9c9fd1dc5b6e5fb2cfa71#diff-ec73b1797eaafa14b354022f28487d6a4d8f5e84ca776012c1c7fcdf6088b392 I tried to rebuild the package with the patch reverted ( following https://www.msys2.org/wiki/Creating-Packages/ ) but after installing, my app fails to link, I guess I have to rebuild all the libraries that depend on it. I wonder if there is an easy way or I have to rebuild all libraries manually.

Unfortunately for me gtk3-demo doesn't crash.

In case you would be happy to reproduce the crash via my app see https://github.com/giuspen/cherrytree#building-cherrytree-on-windows

PenoneG@KUKMW115 MINGW64 ~/git/cherrytree
# gdb ./build/cherrytree.exe
GNU gdb (GDB) 12.1
...
Reading symbols from ./build/cherrytree.exe...
(gdb) r
Starting program: C:\msys64\home\PenoneG\git\cherrytree\build\cherrytree.exe
[New Thread 9180.0x2540]
...
warning: mincore\com\oleaut32\dispatch\ups.cpp(2122)\OLEAUT32.dll!00007FFAFDD39DD6: (caller: 00007FFAFDD391E9) ReturnHr(1) tid
(477c) 8002801D Library not registered.
[New Thread 9180.0x5c30]
[Thread 9180.0x5c30 exited with code 0]
[New Thread 9180.0x5568]
[New Thread 9180.0x5320]
[Thread 9180.0x5568 exited with code 0]
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(1) tid(a88) 80070002 The system cannot find the file specified.
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(2) tid(a88) 80070002 The system cannot find the file specified.
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(3) tid(a88) 80070002 The system cannot find the file specified.
[Thread 9180.0x5320 exited with code 0]
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(4) tid(a88) 80070002 The system cannot find the file specified.
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(5) tid(a88) 80070002 The system cannot find the file specified.
warning: onecore\com\combase\registrationstore\registrationstore.cpp(7759)\combase.dll!00007FFAFD901F64: (caller: 00007FFAFD99
5B43) ReturnHr(6) tid(a88) 80070002 The system cannot find the file specified.
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FF
AFE01B23E) LogHr(1) tid(a88) 80070057 The parameter is incorrect.
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FF
AFE01B23E) LogHr(2) tid(a88) 80070057 The parameter is incorrect.
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FF
AFE01B23E) LogHr(3) tid(a88) 80070057 The parameter is incorrect.
[New Thread 9180.0x601c]
warning: onecore\com\combase\dcomrem\security.cxx(3071)\combase.dll!00007FFAFD86BF3C: (caller: 00007FFAAE29823E) ReturnHr(7) t
id(601c) 80010117 Call context cannot be accessed after call completed.
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FF
AFE01B23E) LogHr(4) tid(a88) 80070057 The parameter is incorrect.
[New Thread 9180.0x3140]

[Thread 9180.0x59c0 exited with code 0]
[New Thread 9180.0x3a40]
warning: Rejecting native image because native image dependency C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expe
cted
warning:
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FFAFE01B23E) LogHr(5) tid(a88) 80070057 The parameter is incorrect.
warning: com\ole32\oleregistrationenumeration\oleregistrationenumeration.cpp(150)\ole32.dll!00007FFAFE0387C3: (caller: 00007FFAFE01B23E) LogHr(6) tid(a88) 80070057 The parameter is incorrect.
[New Thread 9180.0x1fd4]
[Thread 9180.0x1fd4 exited with code 0]
[Thread 9180.0x4d84 exited with code 0]
warning: Invalid parameter passed to C runtime function.

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffae80b5714 in ?? () from C:\Windows\SYSTEM32\DWrite.dll
(gdb) bt
#0  0x00007ffae80b5714 in ?? () from C:\Windows\SYSTEM32\DWrite.dll
#1  0x00007ffab8371f4c in ?? () from C:\msys64\mingw64\bin\libcairo-2.dll
asctime commented 1 year ago

@giuspen I think this is unrelated. IFAIR CAIRO produces it's own surface output of PDF, PS, printing, etc. Also your debug doesn't say anything about Gtk as being the problem. This bug is for the Gtk.PrintOperation. Maybe you should open a new bug. Thanks.

giuspen commented 1 year ago

Sorry @asctime I'll raise a different bug