writingtool-org / writingtool

GNU Lesser General Public License v2.1
10 stars 1 forks source link

Clicking Buttons Does Nothing in Flatpak Wayland. #12

Open YouCanTouCan opened 1 month ago

YouCanTouCan commented 1 month ago

I was having this issue with the LanguageTool extension, and am still having it with this extension as well (version 1.0). When I click on any of the buttons from the toolbar, simply nothing happens. The extension does work - it is showing me grammar and spelling errors all throughout my writing - but not being able to access the settings is frustrating. If I right-click on an underlined error, there is a WritingTool submenu in the context menu with the same options as the toolbar, but those also do nothing when clicked.

LibreOffice is installed via Flatpak on my Aurora system (an edited version of Kionite, which itself is an immutable version of Fedora). The following is my LibreOffice Version information:

Version: 24.8.2.1 (X86_64) / LibreOffice Community
Build ID: 0f794b6e29741098670a3b95d60478a65d05ef13
CPU threads: 32; OS: Linux 6.10; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Flatpak
Calc: threaded

My Java version is 21.0.4, as installed by default in the Flatpak version of LibreOffice

If, through Flatseal, I turn off Wayland Windowing System suddenly the buttons do work... but LibreOffice lags like crazy, making it largely unusable. If I then disable the WritingTool extension, the lag stops.

Please let me know if there is any more info I can give. This project looks fantastic so far, and I'm still happily using it (just without access to the settings menu!) Thank you for all your hard work!

securegh commented 2 weeks ago

I have similar issue on Fedora 40 X11 windowing, LibreOffice rpm version: Version: 24.2.7.2 (X86_64) Build ID: 420(Build:2) CPU threads: 8; OS: Linux 6.11; UI render: default; VCL: gtk3 Locale: en-US (en_US.UTF-8); UI: en-US

The extension settings buttons/ right click submenu are not responsive, but I am seeing text corrections.

Also, per extension description:

AI support for automatic background checks, manual editing of paragraphs, creation of texts and illustrations (An AI server is required).

@YouCanTouCan Is there any documentation how to set up the extension to work with localAI?

YouCanTouCan commented 2 weeks ago

Interesting, then this may be a general Fedora issue rather than a Wayland or Flatpak issue.

I am not aware of how to set it up to work with localAI, sorry. That would be awesome to do, however, so I would also be curious.

FredKruse commented 2 weeks ago

@YouCanTouCan, @securegh

Please give me a feedback.

BobSoft3000 commented 2 weeks ago

I'm getting the same issue on Flatpak / Kubuntu 24.04.1 LTS

LibreOffice version:

Version: 24.8.3.2 (X86_64) / LibreOffice Community
Build ID: 48a6bac9e7e268aeb4c3483fcf825c94556d9f92
CPU threads: 24; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Flatpak
Calc: threaded

Just updated the extension to latest snapshot (WritingTool_2024-11-14-snapshot.oxt) today.

I'm currently using X11 rather than Wayland.

When I go to Tools/Options/LibreOffice/Advanced, the Java version shows as Vendor Flathub / Version 21.0.5.

When I go to Tools/Options/Languages and Locales/Writing Aids, WritingTool is ticked in the 'Available Language Models' section

If I go to Tools/WritingTool/Options in an empty document, an almost invisible window pops up in the middle of one of my screens (2 monitors). The window only appears to be 1 pixel wide and 64 tall. I can use KDE/Plasma 'Window Rules' to match the "Window class (application)" of "org-writingtool-writingtool" then force it to a minimum size (e.g. 300x200). But the window only shows a blank titlebar with the 'WT' logo, and white space underneath.


Have also just tested Canonical's SNAP version of LibreOffice on the same system:

Version: 24.8.3.2 (X86_64) / LibreOffice Community
Build ID: e14c9fdd1f585efcbb2c5363087a99d20928d522
CPU threads: 24; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Calc: threaded

When I go to Tools/Options/Languages and Locales/Writing Aids, WritingTool is ticked in the 'Available Language Models' section

When I go to Tools/Options/LibreOffice/Advanced, the Java version shows as Vendor Ubuntu / Version 21.0.5.

The same issues as above with the 'tiny' window, which I can force large in KDE/plasma settings. (I also tried without this plasma, but without success)


Also tested Ubuntu .deb version of LibreOffice on same system:

Version: 24.2.6.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 24; OS: Linux 6.8; UI render: default; VCL: x11
Locale: en-GB (en_GB.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.6-0ubuntu0.24.04.1
Calc: threaded

When I go to Tools/Options/Languages and Locales/Writing Aids, WritingTool is ticked in the 'Available Language Models' section

When I go to Tools/Options/LibreOffice/Advanced, the Java version shows as Vendor Ubuntu / Version 21.0.5.

The same issues as above with the 'tiny' window, which I can force large in KDE/plasma settings. (I also tried without this plasma, but no success)

I tried switching to Java 17 using the 'openjdk-17-jre(-headless)' packages, and selecting that in LibreOffice, but this only had the effect of changing the 'WT' icon in the titlebar to the a Java icon.

Additionally when using the '.deb' version, I can inspect a logfile at: $HOME/.config/LanguageTool/LibreOffice/LanguageTool.log

this contains the following:

WritingTool log from Fri Nov 15 13:08:11 GMT 2024

WritingTool 1.1-SNAPSHOT (2024-11-14 22:20:08 +0000)
LanguageTool 6.6-SNAPSHOT (2024-11-14 16:45:45 +0000, d4cee13)
OS: Linux 6.8.0-48-generic on amd64
LibreOffice 24.2.6.2 (The Document Foundation, Debian and Ubuntu), en-US
Java-Version: 17.0.13, max. Heap-Space: 16056 MB, LT Heap Space Limit: 14450 MB

java.lang.InternalError: java.lang.reflect.InvocationTargetException
        at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
        at java.desktop/java.awt.Font.getFont2D(Font.java:526)
        at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:265)
        at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:151)
        at java.desktop/sun.font.FontUtilities.getCompositeFontUIResource(FontUtilities.java:399)
        at java.desktop/com.sun.java.swing.plaf.gtk.PangoFonts.lookupFont(PangoFonts.java:204)
        at java.desktop/com.sun.java.swing.plaf.gtk.GTKLookAndFeel.getGTKStyleFactory(GTKLookAndFeel.java:1582)
        at java.desktop/com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1546)
        at java.desktop/com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initialize(GTKLookAndFeel.java:1439)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:592)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:639)
        at org.writingtool.WtDocumentsHandler.setJavaLookAndFeel(WtDocumentsHandler.java:2068)
        at org.writingtool.WtDocumentsHandler.getCheckResults(WtDocumentsHandler.java:239)
        at org.writingtool.WtDocumentsHandler.doProofreading(WtDocumentsHandler.java:225)
        at org.writingtool.WritingTool.doProofreading(WritingTool.java:83)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
        ... 16 more
Caused by: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "platName" is null
        at java.desktop/sun.awt.X11FontManager.getFileNameFromPlatformName(X11FontManager.java:162)
        at java.desktop/sun.font.SunFontManager.initCompositeFonts(SunFontManager.java:3133)
        at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:451)
        at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:315)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:315)
        at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
        at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
        ... 22 more

Also tried all of the above in Wayland on the same system (Flatpak, Snap, Deb with JRE17, Deb with JRE21) but still no visible windows.

FredKruse commented 2 weeks ago

It seems there is a problem with the java UIManager as the log file shows. I tried to catch the error and switch back to the default system look and feel. Currently, I don't have a test environment for this system, so please test it with tomorrow's snapshot. You will find it here: https://writingtool.org/writingtool/snapshots/

securegh commented 2 weeks ago

It seems there is a problem with the java UIManager as the log file shows. I tried to catch the error and switch back to the default system look and feel. Currently, I don't have a test environment for this system, so please test it with tomorrow's snapshot. You will find it here: https://writingtool.org/writingtool/snapshots/

That would be the 2024/11/16 snapshot? Looking forward to testing it out!

BobSoft3000 commented 2 weeks ago

I believe snapshot WritingTool_2024-11-15-snapshot.oxt was generated/published a few hours after the commit, so I've just tested all my scenarios again.

Unfortunately, it hasn't fixed the problem on any of them for me - I'm just getting different Java errors.

I ran through all 8 scenarios on Kubuntu LTS (as above) using Flatpak, Snap, Deb with JRE 17, and Deb with JRE 21, using Wayland and X11. For each install, I ensured that the extension was updated to 2024-11-15 snapshot in LibreOffice first (as the Flatpak, Snap, and Deb versions all store their configs/extensions separately).

Logs below (created with typescript), but with some user info obscured. In each case, I launched LibreOffice from the command line, opened a new 'Writer' document, typed some text, clicked the 'Options' then 'About' buttons in the WritingTool toolbar, then exited LibreOffice.

x11-typescript-snap-options-then-about.txt x11-typescript-flatpak-options-then-about.txt x11-typescript-deb-JRE21.0.5-options-then-about.txt x11-typescript-deb-JRE17.0.13-options-then-about.txt wl-typescript-snap-options-then-about.txt wl-typescript-flatpak-options-then-about.txt wl-typescript-deb-JRE21.0.5-options-then-about.txt wl-typescript-deb-JRE17.0.13-options-then-about.txt

securegh commented 2 weeks ago

@BobSoft3000 as soon as @FredKruse confirms the snapshot with the fix, I would test it out on my fedora setup.

FredKruse commented 1 week ago

I found two problems:

  1. Fedora installs openjdk-headless by default. That is not enough to run java applications with a GUI. So, please install full openjdk ( >= 17) to run WritingTool. I couldn't test all the different systems. So please ensure that full JDK is installed on your machines.
  2. Some of the log files from @BobSoft3000 seem to show another problem with GTK. I have integrated a query that ensures that a GTK look-and-feel is installed on the machine (use the system look and feel otherwise). It is available from WritingTool_2024-11-17-snapshot.oxt.
BobSoft3000 commented 1 week ago

Just tested everything again with WritingTool_2024-11-17-snapshot.oxt, but unfortunately it doesn’t seem to have made any visible difference. I’m assuming this is more of a general Linux issue rather than something specific to Flatpak/Snap/Packaged LibreOffice, or X11/Wayland?

My Java coding experience is limited, so I’m reluctant to draw conclusions from the errors shown, but would it be possible to document the build process somewhere for making the snapshot.oxt files? I can see in the LanguageTool Github repo there are a few build scripts, but can’t find equivalents here.

wl-snap-options-then-about.txt wl-flatpak-options-then-about.txt wl-deb_jre21.0.5-options-then-about.txt wl-deb_jre17.0.13-options-then-about.txt x11-snap-options-then-about.txt x11-flatpak-options-then-about.txt x11-deb_jre21.0.5-options-then-about.txt x11-deb_jre17.0.13-options-then-about.txt

BobSoft3000 commented 1 week ago

Small update, but I'm guessing some/all of my above issues (all Kubuntu 24.04.1 LTS) could potentially be on my end, either through broken configs or other issues. I've just installed a Fedora 41 Virtual Machine and used the built-in LibreOffice in that (in Wayland), using WritingTool_2024-11-17-snapshot.oxt, and I do get configuration windows.

Flatpak of LibreOffice in Fedora/Wayland was still problematic though. wl-fed-flatpak-wl-options-then-about.txt

FredKruse commented 1 week ago

@BobSoft3000 It looks like you only have openjdk-headless installed. Try installing e.g. openjdk-17-jdk and try again.

FredKruse commented 1 week ago

@BobSoft3000 @securegh @YouCanTouCan Please let me know if the problem is resolved.

BobSoft3000 commented 1 week ago

In my Fedora VM I have both headless and non-headless JREs installed. When I launch the Fedora packaged version of LibreOffice, it appears to use the non-headless JRE and the extension seems to work as intended.

If I use the Flatpak version of LibreOffice, it uses a bundled JRE which I presume is headless. I tried manually changing the JRE path to the system installed one in Flatpak/LO, but the Flatpak sandbox seemingly blocks access to it. There may be a way to bypass that (using Flatseal?) and give LibreOffice more access, but I'm not sure how, and that might open another can of worms.

Maybe this is a problem that any Java based extension (with a UI) will have when trying to use the Flatpak version of LO?

YouCanTouCan commented 1 week ago

Sorry for responding so late - just tried both the WritingTool_2024-11-17-snapshot.oxt, as well as the newest WritingTool_2024-11-19-snapshot.oxt, but I am also seeing no difference. The issue is still happening for me.

Still using Aurora, the edited version of Fedora Kionite, still using the Flatpak version, and still on Wayland.

securegh commented 1 week ago

@BobSoft3000 @securegh @YouCanTouCan Please let me know if the problem is resolved.

Yes, it works, I downloaded and tested the WritingTool_2024-11-20-snapshot.oxt, thank you for the quick fix, I just had to install java-21-openjdk.x86_64 sudo dnf install java-21-openjdk.x86_64 So now, I have access to the settings menu and submenu tools, there might be some needed improvement in for better readability in dark mode. Screenshot from 2024-11-21 02-19-07

I haven't had the chance to test out the AI features, I will give feedback on that soon.

Kind regards!

YouCanTouCan commented 1 week ago

Still no luck on my end. I'm on WritingTool_2024-11-20-snapshot.oxt, and installed java-21-openjdk.x86_64 through rpm-ostree install java-21-openjdk.x86_64, but after a reboot there is still no difference for me, unfortunately. Could this have to do with how the layering of rpm-ostree works?

FredKruse commented 1 week ago

After you have installed the new JRE/JDK, you have to select the correct JRE/JDK in LibreOffice under Tools/Options/LibreOffice/Advanced. Have you done that?

securegh commented 1 week ago

Still no luck on my end. I'm on WritingTool_2024-11-20-snapshot.oxt, and installed java-21-openjdk.x86_64 through rpm-ostree install java-21-openjdk.x86_64, but after a reboot there is still no difference for me, unfortunately. Could this have to do with how the layering of rpm-ostree works?

@YouCanTouCan

The flatpak version of LibreOffice sandbox all of it required dependencies, it won't interact with the OS version of the java OpenJDK. You may want to ask on LibreOffice forum how to set up the flatpak version with java-21-openjdk.x86_64 https://ask.libreoffice.org/

BobSoft3000 commented 1 week ago

It may also be connected to this Flathub issue (how LanguageTool is impacted by the Flatpak sandbox and/or Wayland). https://github.com/flathub/org.libreoffice.LibreOffice/issues/242

securegh commented 1 week ago

@YouCanTouCan

Since you installed java-21-openjdk.x86_64 with rpm-ostree, can you try to manually select the location of the java open jdk installed on your OS. image

On my OS, its : /usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc40.x86_64/ You may have to give the LibreOffice flatpak access to that location using flatseal.

YouCanTouCan commented 1 week ago

Thank you everyone for your help.

I added the location of the java open jdk manually as described, after giving permission through flatseal and finding the location with the help of this old thread . However... after applying it and restarting LibreOffice, I still unfortunately see no difference. Clicking the buttons still does nothing.

I am still using WritingTool_2024-11-20-snapshot.oxt

image

YouCanTouCan commented 1 week ago

After a day of use, I ran into the issue that using java-21-openjdk-21.0.5.0.11-1.fc40.x86_64 would unfortunately cause the buttons and windows added by the Zotero addon to also no longer work - in addition to the WritingTool buttons not working. So, I swapped back to the default JRE in the flatpak.

(side tangent in case someone in the future has this issue: the default JRE no longer showed up in my installed list, but when I deactivated the "use a java runtime environment", restarted my computer, and reopened Libreoffice it prompted me to turn the setting back on. When I did, the flatpak JRE showed up in the list again, and I could swap to it.)

While java-21-openjdk-21.0.5.0.11-1.fc40.x86_64 didn't solve this issue for me anyway, even if it did, I would hesitate to use this as a solution. Installing packages through rpm-ostree already isn't ideal to do on Kionite, and while WritingTool is mostly usable without the buttons working (the biggest loss is the settings menu), Zotero is rendered completely unusable without the buttons. I just wanted to say this in case there was another possible solution that could be pursued without swapping the JRE. If not, then we can continue pursuing this line of fixing it, and I may need to work out the Zotero problem separately. Thank you once again to everyone in this thread for working through this curious problem.

FredKruse commented 6 days ago

I am not familiar with Flatpack, but I understand, that it is running in a sandbox. Isn't it possible to submit a support request (open an issue) to get a full JRE (not only jre-headless) integrated? That would certainly make it easier to install not only WritingTool, but also other LO-extensions that use GUIs.

BobSoft3000 commented 2 days ago

It may be possible to request a 'full' JRE for the LibreOffice Flatpak but with my limited experience, I can't be sure it would resolve this issue. https://www.libreoffice.org/download/flatpak/ notes that Flatpak specific issues should be raised on the Flathub Github page.

Over the past few weeks, I've migrated from Kubuntu LTS to Fedora, so the installed/bundled version of LibreOffice is much more up-to-date and I no longer need the Flatpak version. I realise not everyone can make that switch though. It should be noted too that LibreOffice offers RPM and DEB files for their most recent versions, but these need to be manually download/installed for each update - not sure how that would work on 'immutable' distributions like Kionite.