compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

AwtWindow does not render on KDE Plasma Desktop with freetype2 2.11.0-4

Open maximilianproell opened this issue 3 years ago • 17 comments

I tried to run the Notepad example application on my desktop and everything works, except when I try to open the "Open..." or the "Save" window from the menu bar, I only get a transparent window with visual artifacts. In the terminal I get the following error messages:

` (java:38970): Gtk-WARNING **: 22:03:10.434: drawing failure for widget 'GtkFileChooserDialog': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkLabel': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkGrid': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkFileChooserWidget': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.595: drawing failure for widget 'GtkFileChooserDialog': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.605: drawing failure for widget 'GtkLabel': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.605: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:38970): Gtk-WARNING **: 22:06:47.605: drawing failure for widget 'GtkEventBox': error occurred in libfreetype ... ` My system: Operating System: Manjaro Linux KDE Plasma Version: 5.22.5 KDE Frameworks Version: 5.87.0 Qt Version: 5.15.2 Kernel Version: 5.10.70-1-MANJARO (64-bit) Graphics Platform: X11 Graphics Processor: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2

FreeType version: freetype2 2.11.0-4

maximilianproell avatar Oct 19 '21 20:10 maximilianproell

QU6OU)3@$YUE)YQT}Q B~UA

virogu avatar Oct 20 '21 07:10 virogu

Here is the crash inf 70L(F7K28PN97Z)3EK7ZBK3 o

virogu avatar Oct 20 '21 07:10 virogu

@igordmn does it look like a Compose issue?

akurasov avatar Oct 28 '21 12:10 akurasov

Not sure. It can be a local system issue, a distro issue, or a JDK issue. In the last case, we can bypass it, providing our own implementation of FileChooser, calling the native API directly.

@maximilianproell, do you know, where you can find another File save dialog in the other apps? To check if it works.

igordmn avatar Oct 28 '21 16:10 igordmn

@igordmn I din't find any other usage of AwtWindow in the other examples, everything else which only uses default Compose functions seems to work fine. The FileDialog created in the AwtWindow Composable causes the issue. I only found one similar issue, where someone gets the same errors, but I don't know if it's related: https://www.mail-archive.com/[email protected]/msg1827418.html Either way, the problem also seems to be caused by the freeType version. I also tried setting gsettings set org.gnome.desktop.interface font-antialiasing grayscale which didn't help.

maximilianproell avatar Nov 03 '21 20:11 maximilianproell

I din't find any other usage of AwtWindow in the other examples

I wanted to check if there is the other application (not related to Compose, better some preinstalled application) which able to open the default system file chooser.

igordmn avatar Nov 03 '21 20:11 igordmn

which able to open the default system file chooser.

Ah, yes. For example, all chromium based browsers use the system default file chooser (Brave in my example) and that's just working perfectly fine.

maximilianproell avatar Nov 03 '21 21:11 maximilianproell

I have a draft of another implementation of file chooser (using lwjgl):

https://github.com/JetBrains/compose-jb/tree/components_nativedialogs

It would be great, if you can check it:

git checkout components_nativedialogs
cd components
./gradlew nativedialogs:demo:run

igordmn avatar Nov 04 '21 10:11 igordmn

It would be great, if you can check it:

I just tried that implementation out, but I get exactly the same errors and the file chooser is a blank window with visual artifacts which are influenced by the mouse movement: grafik The errors are again: `(java:4800): Gtk-WARNING **: 13:53:02.139: drawing failure for widget 'GtkFileChooserDialog': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkLabel': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkEventBox': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkRevealer': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkSidebarRow': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkListBox': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkViewport': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkPlacesSidebar': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkPaned': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkFileChooserWidget': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkBox': error occurred in libfreetype

(java:4800): Gtk-WARNING **: 13:53:02.156: drawing failure for widget 'GtkFileChooserDialog': error occurred in libfreetype ... `

maximilianproell avatar Nov 04 '21 12:11 maximilianproell

Thanks!

I am out of options now.

NativeDialogs uses GTK directly.

Either other applications (Brave) use another API, or they pass some specific options, or java somehow interferes.

But my main guess - everything is fine with NativeDialogs/Compose/JDK, it is something broken in the system or in the latest version of some library.

Try to downgrade freetype to 2.10.4+dfsg-1, as this issue says, there is no crash on this version

igordmn avatar Nov 04 '21 13:11 igordmn

Brave

As far as I know, Chromium based browser use their own bundled freetype, so it seems everything work because the version is different.

igordmn avatar Nov 04 '21 13:11 igordmn

Ok I did some further research: I tried the notepad example app on another Manjaro KDE system: The same error happens there (same freetype version is installed, so the problem can be boiled down to the freetype version).

But GTK file choosers work without a problem on all my KDE systems (Thunderbird, Firefox and Gimp use them for example). I also created a minimal JavaFX Application and open the FileChooser like that and it opens just fine: image

NativeDialogs uses GTK directly.

Native Dialogs use QT on KDE and they look different, as it can be seen here: https://askubuntu.com/questions/1150404/kubuntu-18-10-how-do-i-change-this-file-picker I also forced Firefox to use the native KDE file picker as described in that post and it works fine. So both GTK and the KDE native QT based file pickers work. So I guess the problem is in the old Java Swing library, as JavaFX works?

maximilianproell avatar Nov 04 '21 15:11 maximilianproell

NativeDialogs uses GTK directly.

Ah, you mean Swing uses this Library? So does JavaFX also use it?

maximilianproell avatar Nov 04 '21 15:11 maximilianproell

No, Swing doesn't use NativeDialogs library (by "NativeDialogs" I mean the name of the library, not real native dialogs :) ), it probably also uses GTK (#include <gtk/gtk.h>) to open GTK file chooser. NativeDialogs is just a wrapper around GTK/WinApi/AppKit.

I don't know what is used by JavaFX, but my guess it uses JavaFX based file chooser, written from scratch, not the native one.

I also forced Firefox to use the native KDE

Firefox probably also uses a bundled freetype, not the system one.

So we have 2 issues:

  • GTK file chooser probably doesn't work with freetype2 2.11.0-4
  • Swing/NativeDialogs uses GTK file chooser on KDE instead of QT one

igordmn avatar Nov 04 '21 15:11 igordmn

What is the current status regarding this issue?

The problem still persists with Compose version 1.0.1 and freetype2 2.11.1-1. This is a major deal breaker as this also prevents any other AWT component to be correctly rendered (like the Menubar for example) and I can't expect my Linux users to downgrade their freetype2 version. I, for example, can't even do that because of my distribution repository only having the latest version.

TimerErTim avatar Jan 02 '22 11:01 TimerErTim

Any updates?

Burtan avatar Feb 02 '23 20:02 Burtan

If anyone needs a file picker on linux and has the same issues, I ended up using bonsai. At least it works and has consistent design.

AzimMuradov avatar Apr 20 '23 14:04 AzimMuradov

Have the same issues on Arch (Cinnamon), tried various JDKs. The problem only occurs with Compose apps (tried both AWT and Swing solutions), all other applications work fine, even Java Swing apps (e.g. Intellij Idea, JMeter).

JMeter is open-source, I think that's what they use for file dialog. But it still fails to render with ComposeWindow.

Also tried compose-multiplatform-file-picker, same issues :disappointed:

AzimMuradov avatar May 08 '23 16:05 AzimMuradov

Same issue using https://github.com/WonderzGmbH/nativefiledialog-java

Wayland (amd) Gnome 44.2 freetype2-2.13.0-1

AChep avatar Jun 26 '23 14:06 AChep

Current version of compose-multiplatform-file-picker fixed all my issues.

AzimMuradov avatar Aug 28 '23 18:08 AzimMuradov

From what I understand, the problem occurs when using the GTK file picker (from <gtk/gtk.h>) in conjunction with Compose. But when using zenity it works fine (maybe because it's an external process?). When using any of these tools by themselves (without Compose, but from Kotlin code), everything works fine.

Currently, compose-multiplatform-file-picker uses tinyfd by default. On Linux, tinyfd will first try to use zenity if available. That's why compose-multiplatform-file-picker works. Any other solution ends up using bindings to native functions (using JNA) that call <gtk/gtk.h>.

My guess is that Skia or Compose is interfering with GTK or something.

I'll try to add test files soon.

AzimMuradov avatar Sep 03 '23 15:09 AzimMuradov

On my Fedora 39/Fedora 45/JDK 17, this fixed the issue for me:

gsettings set org.gnome.desktop.interface font-antialiasing grayscale

ptitjes avatar Nov 27 '23 12:11 ptitjes

This issue still occurs with lwjgl nfd module, the libfreetype version is 2.13.2-1

KevinT3Hu avatar Dec 26 '23 04:12 KevinT3Hu

This issue still occurs with lwjgl nfd module, the libfreetype version is 2.13.2-1

If it's an option, you can try to use lwjgl tinyfd.

Example:

https://github.com/AzimMuradov/stardew-valley-designer/tree/master/common/cmp-libs/file-dialogs-ui/src/jvmMain/kotlin/io/stardewvalleydesigner/cmplib/filedialogs

Before, I used compose-multiplatform-file-picker, but I ended up creating my own custom solution.

AzimMuradov avatar Dec 27 '23 14:12 AzimMuradov