Restrict the minimize to tray option to x86-64 CPUs?

Issue #66 closed
Guilherme created an issue

Hi!

In my understanding, Java apps are meant to run on practically all CPU architectures out there, but since WD uses a native x86-64 library to make the system tray functionality work, I think it’d be wise to only enable that feature only for supported CPUs.

Otherwise, trying to minimize WD to systray throws an error (this was on aarch64):

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    no swt-gtk-4944r26 in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
    no swt-gtk in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
    no swt in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
    /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: cannot open shared object file: No such file or directory (Possible cause: can't load AMD 64-bit .so on a AARCH64-bit platform)
    Can't load library: /home/gui/.swt/lib/linux/aarch64/libswt-gtk.so
    Can't load library: /home/gui/.swt/lib/linux/aarch64/libswt.so
    /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: cannot open shared object file: No such file or directory (Possible cause: can't load AMD 64-bit .so on a AARCH64-bit platform)

    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:348)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:257)
    at org.eclipse.swt.internal.C.<clinit>(C.java:19)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:209)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:155)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:165)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader.minimizeApplication(WallpaperDownloader.java:2952)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader$2.windowStateChanged(WallpaperDownloader.java:393)
    at java.desktop/java.awt.Window.processWindowStateEvent(Window.java:2161)
    at java.desktop/java.awt.Window.processEvent(Window.java:2044)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The other alternative would be bundling the native SWT library for other CPUs architectures as well…? 🤔

Comments (9)

  1. Eloy García Almadén repo owner

    Hi Guilherme!

    Thanks again for reporting! Where did you run WallpaperDownloader? On a Raspberry Pi?

    I have sent a fix to devel branch. Could you test it? I was about to release version 4.2 this morning when I saw your ticket and decided to hold the release until this is fixed.

    Thank you very much!! 🙂

  2. Guilherme reporter

    I actually ran a (local) Flatpak build emulated via QEMU on my x86-64 CPU.

    I have sent a fix to devel branch. Could you test it?

    Thanks, I’m doing that as we speak. On a side note, I’m getting these two warnings when I compile WD now (after PR #11):

    Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt.gtk.linux.x86_64/3.116.100/org.eclipse.swt.gtk.linux.x86_64-3.116.100.pom                 
    Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt.gtk.linux.x86_64/3.116.100/org.eclipse.swt.gtk.linux.x86_64-3.116.100.pom (2.0 kB at 6.7 kB
    /s)
    Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/maven-metadata.xml
    Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/maven-metadata.xml (952 B at 3.1 kB/s)
    Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/3.116.0/org.eclipse.swt-3.116.0.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/3.116.0/org.eclipse.swt-3.116.0.pom (2.0 kB at 6.3 kB/s)
    [WARNING] The POM for org.eclipse.platform:org.eclipse.swt:jar:3.116.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
    Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/3.116.100/org.eclipse.swt-3.116.100.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/platform/org.eclipse.swt/3.116.100/org.eclipse.swt-3.116.100.pom (2.0 kB at 5.9 kB/s)
    [WARNING] The POM for org.eclipse.platform:org.eclipse.swt:jar:3.116.100 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
    

    Do you happen to know why? It’s actually preventing me from building WD without network access, and I need to fix it before sending 4.2 to Flathub, because they don’t allow building with network access, so the all the maven dependencies have to be put in a separate file.

    Anyways, if I don’t find a fix for this before you release 4.2, I’ll just download the pre-compiled .jar, so not a big deal. 🙂

  3. Guilherme reporter

    Okay, I just tested a build on commit abab8cb6, and while the minimize to tray option isn’t there, WD still tries to load the SWT library when I minimize it:

    $ flatpak run es.estoes.wallpaperDownloader/aarch64
    log4j:WARN File option not set for appender [logfile].
    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
    [10:57:39] INFO  WDConfigManager:76 - Checking configuration...
    [10:57:39] INFO  WDConfigManager:77 - Checking application's directory
    [10:57:39] INFO  PreferencesManager:49 - Creating PreferenceManager instance for the first time...
    [10:57:39] INFO  PreferencesManager:65 - Setting user's configuration file path to /home/gui/.wallpaperdownloader/config.txt
    [10:57:40] INFO  WDConfigManager:86 - Retrieving operating system... Linux
    [10:57:40] INFO  WDConfigManager:109 - Operating System detected: Linux
    [10:57:40] INFO  WDConfigManager:114 - Retrieving CPU architecture... aarch64
    [10:57:40] INFO  WDConfigManager:131 - CPU architecture detected: ARM
    [10:57:40] INFO  WDConfigManager:338 - Downloads directory -> /home/gui/.wallpaperdownloader/downloads
    [10:57:40] INFO  WDConfigManager:369 - Checking blacklist directory...
    [10:57:40] INFO  WDConfigManager:379 - Blacklist directory already exists. Skipping...
    [10:57:40] INFO  WallpaperChanger:73 - Instantiating wallpaper changer...
    [10:57:40] INFO  LinuxWallpaperChanger:55 - Checking XDG_CURRENT_DESKTOP environment variable. Value = GNOME
    [10:57:40] INFO  LinuxWallpaperChanger:98 - Desktop environment detected: GNOME3
    [10:57:47] INFO  WDUtilities:322 - Downloads directory space occupied: 0 %
    [10:57:47] INFO  WDUtilities:232 - Getting all the wallpapers in downloads_directory...
    [10:57:48] INFO  ChangerDaemon:74 - Starting automatically changing process...
    [10:57:48] INFO  Harvester:74 - Initializing providers...
    [10:57:48] INFO  Harvester:184 - Starting harvesting process...
    [10:57:48] INFO  Harvester:74 - Initializing providers...
    [10:57:48] INFO  BackgroundChangingProcess:68 - Available wallpapers linked list is removed in order to build it again freshly if it is necessary
    [10:57:48] INFO  Harvester:207 - No providers configured. Nothing to do.
    [10:57:48] INFO  BackgroundChangingProcess:79 - Automated wallpaper changer process is OFF
    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
        no swt-gtk-4944r26 in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
        no swt-gtk in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
        no swt in java.library.path: [., /usr/java/packages/lib, /lib, /usr/lib]
        /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: cannot open shared object file: No such file or directory (Possible cause: can't load AMD 64-bit .so on a AARCH64-bit platform)
        Can't load library: /home/gui/.swt/lib/linux/aarch64/libswt-gtk.so
        Can't load library: /home/gui/.swt/lib/linux/aarch64/libswt.so
        /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: /home/gui/.swt/lib/linux/aarch64/libswt-gtk-4944r26.so: cannot open shared object file: No such file or directory (Possible cause: can't load AMD 64-bit .so on a AARCH64-bit platform)
    
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:348)
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:257)
        at org.eclipse.swt.internal.C.<clinit>(C.java:19)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:209)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:155)
        at org.eclipse.swt.widgets.Display.<clinit>(Display.java:165)
        at es.estoes.wallpaperDownloader.window.WallpaperDownloader.minimizeApplication(WallpaperDownloader.java:2969)
        at es.estoes.wallpaperDownloader.window.WallpaperDownloader$2.windowStateChanged(WallpaperDownloader.java:393)
        at java.desktop/java.awt.Window.processWindowStateEvent(Window.java:2161)
        at java.desktop/java.awt.Window.processEvent(Window.java:2044)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    

    It’s probably because the system tray option is still enabled in my config.txt:

    es.estoes.wallpaperDownloader.window.system-tray-icon=yes
    

    Thoughts?

  4. Eloy García Almadén repo owner

    Hi!

    You are right. When I execute **mvn clean package** those warnings are thrown, although they are not preventing to finish the build successfully and final jar is created. Why is flatpak preventing to finish the build? All the dependencies should be downloaded during the building process I guess. I’ve been searching and I’ve found this https://github.com/flatpak/flatpak/issues/548 although I don’t know if it is a possible solution to this problem 😕

    On the other hand, in order to test the new fix, you should completely remove ~/.wallpaperdownloader directory and run it for the first time. Doing so, es.estoes.wallpaperDownloader.window.system-tray-icon=yes property should be no and I think this exception shouldn’t appear. Could you test it?

    Thank you very much!!! 🙂

  5. Eloy García Almadén repo owner

    While writing the previous comment I’ve seen that you have create a PR! I’m on it! You are very very fast my friend!

  6. Guilherme reporter

    Why is flatpak preventing to finish the build?

    I can actually build locally with internet access on maven, but to submit any app to Flathub, they disable internet access during the build phase, so you either need to put all project dependencies on a separate file and flatpak-builder will download them before building, OR you can also just package from a pre-compiled jar. When I submitted the app to Flathub, I chose the first option because I believe it adds more transparency to the whole thing. 🙂

    On the other hand, in order to test the new fix, you should completely remove ~/.wallpaperdownloader directory and run it for the first time

    Ah, I see! Removing the directory (or changing es.estoes.wallpaperDownloader.window.system-tray-icon to no) fixes the issue. Thanks!

    While writing the previous comment I’ve seen that you have create a PR! I’m on it! You are very very fast my friend!

    🤣 Cheers!

  7. Log in to comment